Forum Moderators: travelin cat

Message Too Old, No Replies

JS won't work on Mac

Driving me crazy!

         

4string

1:59 pm on Aug 20, 2004 (gmt 0)

10+ Year Member



I can't figure out why the JS on my site works for anyone with a PC, but not a MAC. Naturally I don't have a MAC to test it out on. I'm using a sound on mouseover javascript with midi files. It's the whole point of the site. So it stinks for a Mac person to come and find a useless site. Any ideas why a Mac wouldn't read it the same way?

Any help is appreciated!

BjarneDM

9:19 am on Aug 22, 2004 (gmt 0)

10+ Year Member



This is a completely clueless question - not even Sherlock Holmes would be able to find a solution based on the information given.

We need:
1) a reference to your website in your profile so we can access your script
2) a list of browsers you've tried on WinTel

Offhand I'ld say that the most commom reason a javascript doesn't work on Mac browsers is the totally ignorant use of document.all().

4string

2:13 pm on Aug 22, 2004 (gmt 0)

10+ Year Member



Very sorry. I didn't know if there was some simple common problem I didn't know about and I'm very trained not to post URLs or give specifics on WW. So I was trying to stay general at first.

Site in question is in my profile.

I've tried it on IE 6, NS 7, and Opera. And I've tried it on a number of other machines using mostly different versions of IE. It only doesn't work for people with Macs and they claim to have tried current versions of IE and Safari. They have JS enabled and are able to run other JS.

If there was anywhere I'd expect to run into Sherlock Holmes, it'd be here! :)

Thanks for taking the time to reply.

outrun

2:22 pm on Aug 22, 2004 (gmt 0)

10+ Year Member



4string Your website wont show in your profile until youve reached a certain amount of posts try posting portions of your javascript here, if its not too much post all of it.

regards,
Mark

4string

3:08 pm on Aug 22, 2004 (gmt 0)

10+ Year Member



It'd probably be easier to sticky someone with the url if anyone wants to take a look.

On an image map I have areas like:
<area shape="rect" coords="0,75,770,113" onmouseover="playSound(5)" onmouseout="stopSound(5)">

Here is the code. One of those timesaving cut & paste jobs...

// Sound on Mouseover javascript supplied by [snip]

var aySound = new Array();
// PLACE YOUR SOUND FILES BELOW
aySound[0] = "B.mid";
aySound[1] = "E.mid";
aySound[2] = "A.mid";
aySound[3] = "D.mid";
aySound[4] = "G.mid";
aySound[5] = "C.mid";
// Don't alter anything below this line

IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
ver4 = IE¦¦NS? 1:0;
onload=auPreload;

function auPreload() {
if (!ver4) return;
if (NS) auEmb = new Layer(0,window);
else {
Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
document.body.insertAdjacentHTML("BeforeEnd",Str);
}
var Str = '';
for (i=0;i<aySound.length;i++)
Str += "<EMBED SRC='"+aySound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
if (IE) auEmb.innerHTML = Str;
else {
auEmb.document.open();
auEmb.document.write(Str);
auEmb.document.close();
}
auCon = IE? document.all.soundfiles:auEmb;
auCon.control = auCtrl;
}
function auCtrl(whSound,play) {
if (IE) this.src = play? aySound[whSound]:'';
else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
}
function playSound(whSound) { if (window.auCon) auCon.control(whSound,true); }
function stopSound(whSound) { if (window.auCon) auCon.control(whSound,false); }
//--></script>

Thanks.

BjarneDM

6:08 pm on Aug 22, 2004 (gmt 0)

10+ Year Member



IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;

IE on mac doesn't have document.all .
LiveAudio isn't an available plugin. As far as I've been able to discern LiveAudio is a Netscape 3 & 4 technology that has been discontinued. Sound on Mac is handled by "QuickTime Plug-in 6.5.1" or "Windows Media Plugin".
Your script doesn't detect Safari or OmniWeb or Opera.

Thus your script simply exits.

if (NS) auEmb = new Layer(0,window);

This is supported in NS4 *only*! - total legacy coding worth nothing

Conclusion:
Your script is written to work only in IE under WinTel or NS4 (any platform).
It won't work with anything else.

Advise (and only cure):
Rewrite the script to use the w3c DOM
ANY use of 'document.all' is bound to give you serious trouble if you want your script to work in anything else than IE for WinTel.

4string

4:06 am on Aug 23, 2004 (gmt 0)

10+ Year Member



OK. Thanks for the thorough explanation. I'll work on it this week if I can get to it.