mouseover on all browsers

Discussion in 'Javascript' started by Nick, Oct 27, 2003.

  1. Nick

    Nick Guest

    I can't make out why this won't work in iexplorer (even when I change
    'Netscape'). The mouse over works fine in >Netscape 4 and Opera 5 and
    7. Is it a simple fix or is that wishful thinking?

    Regards
    N

    etc
    </HEAD>

    <script language="JavaScript">
    <!--
    function bboatssw_exchange_src(name, rpath, nsdoc)
    {
    str = (navigator.appName == 'Netscape') ? nsdoc+'.'+name :
    'document.all.'+name;
    img = eval(str);
    if (img) {
    if (img.altsrc == null) {
    img.altsrc = img.src;
    img.src = rpath;
    } else {
    var temp = img.src;
    img.src = img.altsrc;
    img.altsrc = temp;
    }
    }
    }

    function bboatssw_preload_img()
    {
    var img_list = bboatssw_preload_img.arguments;
    if (document.preloadlist == null)
    document.preloadlist = new Array();
    var top = document.preloadlist.length;
    for (var i=0; i < img_list.length; i++) {
    document.preloadlist[top+i] = new Image;
    document.preloadlist[top+i].src = img_list;
    }
    }

    //-->
    </script>

    <BODY bgColor=#000000 leftMargin=0 topMargin=0 marginheight="0"
    marginwidth="0" text="#f7e6eb" link=#dbcae6
    vLink=#cbb0db aLink=#cccae6>
    <TABLE border=0 cellPadding=0 cellSpacing=0>

    <TR>
    <TD width="138"><IMG height=189 src="pieces/one.jpg"
    width=138></TD>
    <TD width="586" valign="top"><IMG height=189 src="pieces/two2.jpg"
    width=611></TD>
    </TR>
    <TR>
    <TD vAlign=top width="138" height="414"> <IMG height=46
    src="pieces/three.jpg" width=138>
    <A onmouseover="bboatssw_exchange_src('image1', 'pieces/fourover.jpg',
    'document')" onmouseout
    ="bboatssw_exchange_src('image1', 'pieces/fourover.jpg', 'document')"
    href="bullshit1.html" ><IMG height=47
    alt=four.jpg src="pieces/four.jpg" width=138 border=0
    name=image1></A>

    ETC ETC
     
    Nick, Oct 27, 2003
    #1
    1. Advertising

  2. (Nick) writes:

    > I can't make out why this won't work


    What doesn't work? Does nothing happen or does the wrong thing happen?

    > in iexplorer (even when I change 'Netscape'). The mouse over works
    > fine in >Netscape 4 and Opera 5 and 7. Is it a simple fix or is that
    > wishful thinking?


    > <script language="JavaScript">


    The type attribute is required in HTML 4.0+
    <script type="text/javascript">

    > <!--


    HTML comments are not needed in Javascript.

    > function bboatssw_exchange_src(name, rpath, nsdoc)
    > {


    > str = (navigator.appName == 'Netscape') ? nsdoc+'.'+name :
    > 'document.all.'+name;
    > img = eval(str);


    Declare your variables as local to avoid polluting the global
    namespace.

    You never need eval to access object properties or variables.

    These two lines can be changed to just:
    var img = document.images[name];

    It works in pretty much any browser later than Netscape 2.

    /L
    --
    Lasse Reichstein Nielsen -
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
    'Faith without judgement merely degrades the spirit divine.'
     
    Lasse Reichstein Nielsen, Oct 27, 2003
    #2
    1. Advertising

  3. Nick

    Nick Guest

    Lasse Reichstein Nielsen <> wrote in message news:<>...
    > (Nick) writes:
    >
    > > I can't make out why this won't work

    >
    > What doesn't work? Does nothing happen or does the wrong thing happen?
    >

    Thanks for replying. "Doesn't work" in this context means that
    images do not even appear - just the cyber box where they should
    (either mouse over or not)- in IE, where as everything is normal in
    the other browsers (ie the images, differing shades, alternate on
    mouseover off movement)work as expected.


    Thanks again for your input
    N
     
    Nick, Oct 28, 2003
    #3
  4. Nick

    Nick Guest

    Additionally replaced the two lines with the one you suggested. The
    good news is it still works as before. The bad news but still not in
    IE (v5.5). No images anywhere (even the ones that don't involve a
    mousever. Maybe that's a clue. Does it require a different type of
    dir path to the images?).

    Regards
    N
     
    Nick, Oct 28, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TJmaster
    Replies:
    1
    Views:
    1,486
    Karl Seguin
    Feb 24, 2005
  2. Francis Ardi
    Replies:
    3
    Views:
    451
    Sudsy
    Jul 10, 2003
  3. Francis Ardi
    Replies:
    0
    Views:
    483
    Francis Ardi
    Jul 10, 2003
  4. osman
    Replies:
    5
    Views:
    405
    I Osman
    Dec 2, 2004
  5. El Kabong

    Browsers, browsers! Quo vadis?

    El Kabong, May 11, 2007, in forum: HTML
    Replies:
    23
    Views:
    943
    dorayme
    May 13, 2007
Loading...

Share This Page