Netscape compatibility

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon Wigzell

    Netscape compatibility

    I pulled some 3rd party code off the internet that makes a span visible on
    mouseover of a link. It works fine in IE, doesn't work for Netscape, it goes
    into "Unknown", see it here :
    http://www.studioapriori.com/cavendishSimon/divtest.htm How can I make it
    work for all browsers? (Within reason of course!)

    <html>
    <head>
    <style type="text/css"><!--
    ..absolute { position:absolu te; visibility:hidd en; }
    //--></style>
    </head>
    <body>
    <script language="JavaS cript"><!--
    function showOffset(obje ct,x,y) {
    if (document.layer s && document.layers[object]) {
    document.layers[object].left += x;
    document.layers[object].top += y;
    document.layers[object].visibility = 'visible';
    }
    else if (document.all) {
    document.all[object].style.posLeft = document.all[object].offsetLeft
    + x;
    document.all[object].style.posTop = document.all[object].offsetTop +
    y;
    document.all[object].style.visibili ty = 'visible';
    }
    else {
    alert("Unknown" );
    }
    }

    function hideOffset(obje ct,x,y) {
    if (document.layer s && document.layers[object]) {
    document.layers[object].visibility = 'hidden';
    document.layers[object].left -= x;
    document.layers[object].top -= y;
    }
    else if (document.all) {
    document.all[object].style.visibili ty = 'hidden';
    document.all[object].style.posLeft -= x;
    document.all[object].style.posTop -= y;
    }
    }
    //--></script>
    <span id="myLayer6" class="absolute "><img src="img/privacy_policy_ roll.gif"
    width="219" height="150"></span>

    <a href="nextpage. htm" onMouseover="sh owOffset('myLay er6',100,100)"
    onMouseout="hid eOffset('myLaye r6',100,100)">e xample 6</a>
    </body>
    </html>


  • Simon Wigzell

    #2
    Re: Netscape compatibility

    snip

    It's okay, I found the answer, still, which browser will activate the first
    if statement block? I might as well do a proper test - opera? mozilla?

    function showOffset(obje ct,x,y) {
    if (document.layer s && document.layers[object]) {/* ??? */
    document.layers[object].left = x;
    document.layers[object].top = y;
    document.layers[object].visibility = 'visible';
    }
    else if (document.all) { /* IE */
    document.all[object].style.posLeft = x;
    document.all[object].style.posTop = y;
    document.all[object].style.visibili ty = 'visible';
    }
    else if (document.getEl ementById){ /* Netscape */
    document.getEle mentById(object ).style.left = x;
    document.getEle mentById(object ).style.top = y;
    document.getEle mentById(object ).style.visibil ity = 'visible';
    }
    else {
    alert("Unknown" );
    }
    }


    Comment

    • Ron

      #3
      Re: Netscape compatibility

      Simon Wigzell wrote:
      [color=blue]
      >snip
      >
      >It's okay, I found the answer, still, which browser will activate the first
      >if statement block? I might as well do a proper test - opera? mozilla?
      >
      >function showOffset(obje ct,x,y) {
      > if (document.layer s && document.layers[object]) {/* ??? */
      > document.layers[object].left = x;
      > document.layers[object].top = y;
      > document.layers[object].visibility = 'visible';
      > }
      > else if (document.all) { /* IE */
      > document.all[object].style.posLeft = x;
      > document.all[object].style.posTop = y;
      > document.all[object].style.visibili ty = 'visible';
      > }
      > else if (document.getEl ementById){ /* Netscape */
      > document.getEle mentById(object ).style.left = x;
      > document.getEle mentById(object ).style.top = y;
      > document.getEle mentById(object ).style.visibil ity = 'visible';
      > }
      > else {
      > alert("Unknown" );
      > }
      >}
      >
      >
      >
      >[/color]
      I believe document.layers is a deprecated NN4 interface.
      document.getEle mentById is present in all contemporary
      standards-compliant browsers (Opera, Mozilla and other Gecko-based) and
      IE5.5+.

      Comment

      • Lasse Reichstein Nielsen

        #4
        Re: Netscape compatibility

        "Simon Wigzell" <simonwigzell@s haw.ca> writes:
        [color=blue]
        > It's okay, I found the answer, still, which browser will activate the first
        > if statement block? I might as well do a proper test - opera? mozilla?
        >
        > function showOffset(obje ct,x,y) {
        > if (document.layer s && document.layers[object]) {/* ??? */[/color]

        I only know one browser apart from Netscape 4 that has
        document.layers , and that is OmniWeb. As far as I remember having been
        told, it is not functional, so the second half of the test is likely
        to fail.
        [color=blue]
        > document.layers[object].left = x;
        > document.layers[object].top = y;
        > document.layers[object].visibility = 'visible';
        > }
        > else if (document.all) { /* IE */[/color]

        That is not correct. There are browsers apart from IE that understand
        document.all.
        [color=blue]
        > document.all[object].style.posLeft = x;[/color]

        Since posLeft is not a standard CSS property (so I assume it's
        specific to IE), it is likely that non-IE browsers that has
        document.all will fail this line. Change to:
        document.all[object].style.left = x + "px";
        [color=blue]
        > document.all[object].style.posTop = y;[/color]

        ditto
        [color=blue]
        > document.all[object].style.visibili ty = 'visible';
        > }
        > else if (document.getEl ementById){ /* Netscape */[/color]

        This is also not the case. There are many, many browsers that support
        document.getEle mentById. Some of these will also support document.all,
        but I doubt that Gecko based browsers are the only ones with only
        document.gEBI.
        [color=blue]
        > document.getEle mentById(object ).style.left = x;[/color]

        Gecko based browsers (which is what I assume you mean by "Netscape")
        in standards compliant mode will ignore this line, because you lack
        the unit. Change to:

        document.getEle mentById(object ).style.left = x + "px";

        If your page is not triggering standards compliant mode, you should
        change it. Quirks mode is for compatability with old and badly written
        pages, and not something one should author new pages for.


        Generally, I would test for document.gEBI first instead of last. Any
        new browser will understand that. Should it also support document.all
        or even document.layers , it should not be mistaken for an old Netscape
        or IE.

        /L
        --
        Lasse Reichstein Nielsen - lrn@hotpop.com
        DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
        'Faith without judgement merely degrades the spirit divine.'

        Comment

        • Chris

          #5
          Re: Netscape compatibility

          Netscape is incompatible with itself half the time, - don't even bother
          trying ;)


          "Simon Wigzell" <simonwigzell@s haw.ca> wrote in message
          news:CHAmc.3924 41$Ig.365455@pd 7tw2no...[color=blue]
          > I pulled some 3rd party code off the internet that makes a span visible on
          > mouseover of a link. It works fine in IE, doesn't work for Netscape, it[/color]
          goes[color=blue]
          > into "Unknown", see it here :
          > http://www.studioapriori.com/cavendishSimon/divtest.htm How can I make it
          > work for all browsers? (Within reason of course!)
          >
          > <html>
          > <head>
          > <style type="text/css"><!--
          > .absolute { position:absolu te; visibility:hidd en; }
          > //--></style>
          > </head>
          > <body>
          > <script language="JavaS cript"><!--
          > function showOffset(obje ct,x,y) {
          > if (document.layer s && document.layers[object]) {
          > document.layers[object].left += x;
          > document.layers[object].top += y;
          > document.layers[object].visibility = 'visible';
          > }
          > else if (document.all) {
          > document.all[object].style.posLeft =[/color]
          document.all[object].offsetLeft[color=blue]
          > + x;
          > document.all[object].style.posTop = document.all[object].offsetTop[/color]
          +[color=blue]
          > y;
          > document.all[object].style.visibili ty = 'visible';
          > }
          > else {
          > alert("Unknown" );
          > }
          > }
          >
          > function hideOffset(obje ct,x,y) {
          > if (document.layer s && document.layers[object]) {
          > document.layers[object].visibility = 'hidden';
          > document.layers[object].left -= x;
          > document.layers[object].top -= y;
          > }
          > else if (document.all) {
          > document.all[object].style.visibili ty = 'hidden';
          > document.all[object].style.posLeft -= x;
          > document.all[object].style.posTop -= y;
          > }
          > }
          > //--></script>
          > <span id="myLayer6" class="absolute "><img[/color]
          src="img/privacy_policy_ roll.gif"[color=blue]
          > width="219" height="150"></span>
          >
          > <a href="nextpage. htm" onMouseover="sh owOffset('myLay er6',100,100)"
          > onMouseout="hid eOffset('myLaye r6',100,100)">e xample 6</a>
          > </body>
          > </html>
          >
          >[/color]


          Comment

          • Simon Wigzell

            #6
            Re: Netscape compatibility

            Thanks to all who replied, I won't worry about it then.


            Comment

            Working...