help with function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Key Bohn

    help with function

    var NN4 = document.layers ? true : false; //Netscape Navigator 4.x.
    var IE4 = document.all? true : false; // IE version 4 and above.
    var agent = navigator.userA gent.toLowerCas e();

    function display(flash) {
    if (IE4) {
    document.all[flash].style.visibili ty = "visible";
    }
    if (agent.indexOf( "mac") != -1)
    {
    document.layers[flash].visibility = "hide";
    }

    else if(NN4) {
    document.layers[flash].visibility = "hide";
    }
    }


    This is being used to detect a user's browser and platform and show or hide
    a layer containing a small flash movie depending. It's supposed to show in
    IE for PC (which works) hide in Netscape for PC (also works) and hide for
    IE MAcintosh. That last one does not work and it shows the layer. Can
    anyone tell me why?

  • Lasse Reichstein Nielsen

    #2
    Re: help with function

    ken@nospam.com (Key Bohn) writes:
    [color=blue]
    > This is being used to detect a user's browser and platform[/color]

    .... which it does pretty badly ...
    [color=blue]
    > and show or hide a layer containing a small flash movie depending.[/color]
    [color=blue]
    > It's supposed to show in IE for PC (which works) hide in Netscape
    > for PC (also works)[/color]

    It works in Netscape 4, which is close to extinct (not close *enough*,
    but close), but not in Netscape 6/7 (or other browsers based on Mozilla)
    [color=blue]
    > and hide for IE MAcintosh. That last one does
    > not work and it shows the layer. Can anyone tell me why?[/color]

    I have a guess, without having a Macintosh. You should also be aware
    that the Safari browser is quickly gaining marketshare on the Macintosh,
    and there is yet another browser wher your code doesn't work.

    So, for the solution to your problem:
    [color=blue]
    > if (agent.indexOf( "mac") != -1)
    > {
    > document.layers[flash].visibility = "hide";
    > }[/color]

    IE doesn't have document.layers . This should be a copy of the IE line,
    not the Netscape line, i.e.,
    [color=blue]
    > document.all[flash].style.visibili ty = "hidden";[/color]

    (it is "hidden", not "hide", although both works in Netscape 4).


    Why do you want your page to only work on IE in windows, when
    it is fairly easy to make it work in all browsers?
    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • kaeli

      #3
      Re: help with function

      In article <q1L9b.366892$c F.109845@rwcrns c53>, ken@nospam.com
      enlightened us with...[color=blue]
      > }
      > if (agent.indexOf( "mac") != -1)
      > {[/color]

      Are you sure this is the exact spelling in the user agent? This is case-
      sensitive. Mac != mac.


      -------------------------------------------------
      ~kaeli~
      Hey, if you got it flaunt it! If you don't, stare
      at someone who does. Just don't lick the TV screen,
      it leaves streaks.


      -------------------------------------------------

      Comment

      Working...