Welcome to WebmasterWorld Guest from 54.146.248.111

Forum Moderators: open

Message Too Old, No Replies

How do I stop a certain javascript working on the Mac?

stop a script workin in mac browsers

     

Googly

3:11 pm on Dec 10, 2002 (gmt 0)



Can anyone tell me what i can add to a javascript function to stop it working on mac browsers?

Cheers
Googly

ytswy

3:22 pm on Dec 10, 2002 (gmt 0)

10+ Year Member



I found this somewhere I forget where.

Use the condition:
if (navigator.appVersion.indexOf('Mac')!= -1)

This will evaluate as true on Macs, otherwise false [disclaimer: I haven't tested it fully since I didn't implement it]

SethCall

3:24 pm on Dec 10, 2002 (gmt 0)

10+ Year Member



Well, the main site that contains the "ultimate browser sniffer" script (which is very good) is on netscape, and at this time, it seems to be gone ;(

So I believe I found the same script at this site

[ksu.edu...]

the meat of the script you are looking for is a bit farther down.

Googly

4:28 pm on Dec 10, 2002 (gmt 0)



Blimey! I just re-read the title I put in for this thread! BACK? and MAC! A bit different! Must be one of those days!

Googly

Googly

5:25 pm on Dec 10, 2002 (gmt 0)



Okay sorry, but i've tried and failed. I'm not exactly great at understanding javascript. Could someone be kind enough to add the required code below to make sure it doesn't work on a Mac.

function toggleVisibility(id, NNtype, IEtype, WC3type) {
if (document.getElementById) {
eval("document.getElementById(id).style.visibility = \"" + WC3type + "\"");
} else {
if (document.layers) {
document.layers[id].visibility = NNtype;
} else {
if (document.all) {
eval("document.all." + id + ".style.visibility = \"" + IEtype + "\"");
}
}
}
}

Cheers
Googly

korkus2000

6:22 pm on Dec 10, 2002 (gmt 0)

WebmasterWorld Senior Member korkus2000 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



if (navigator.appVersion.indexOf('Mac')!= -1){
alert("Wow, you use a Mac!");
}else{

function toggleVisibility(id, NNtype, IEtype, WC3type) {
if (document.getElementById) {
eval("document.getElementById(id).style.visibility = \"" + WC3type + "\"");
} else {
if (document.layers) {
document.layers[id].visibility = NNtype;
} else {
if (document.all) {
eval("document.all." + id + ".style.visibility = \"" + IEtype + "\"");
}}}}}

SethCall

9:00 pm on Dec 10, 2002 (gmt 0)

10+ Year Member



or maybe

var MacIsNotPresent = 1; //this variable should be global, so //your other javascript can find out if it should execute or //not

function setMacPresense(){
if (navigator.appVersion.indexOf('Mac')!= -1)
MacIsNotPresent=0; //or false
}

funtion JustAnExample(){
//then, you could prepend all your other scripts with:

if(MacIsNotPresent){
//****do all your Windows/Linux stuff***
}else{
//do all your Mac stuff (which is nothing, in this
//case)
}
}
<body onload="setMacPresense();">

i guess this should do it!

 

Featured Threads

Hot Threads This Week

Hot Threads This Month