By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,729 Members | 1,559 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,729 IT Pros & Developers. It's quick & easy.

help with function

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.