471,066 Members | 920 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

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.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?

Jul 20 '05 #1
2 1619
ke*@nospam.com (Key Bohn) writes:
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
In article <q1L9b.366892$cF.109845@rwcrnsc53>, ke*@nospam.com
enlightened us with...
}
if (agent.indexOf("mac") != -1)
{


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.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Alan Bashy | last post: by
2 posts views Thread by Jackson Yap | last post: by
5 posts views Thread by Craig Keightley | last post: by
1 post views Thread by Michael D. Reed | last post: by
1 post views Thread by Rahul | last post: by
4 posts views Thread by Stef Mientki | last post: by
22 posts views Thread by Amali | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.