help with function

K

Key Bohn

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

function display(flash) {
if (IE4) {
document.all[flash].style.visibility = "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?
 
L

Lasse Reichstein Nielsen

This is being used to detect a user's browser and platform

.... which it does pretty badly ...
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)

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)
and hide for IE MAcintosh. That last one does
not work and it shows the layer. Can anyone tell me why?

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:
if (agent.indexOf("mac") != -1)
{
document.layers[flash].visibility = "hide";
}

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

(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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,090
Messages
2,570,603
Members
47,223
Latest member
smithjens316

Latest Threads

Top