Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MAC vs Windows javascript. Pls enlighten guys.

Status
Not open for further replies.

icy80

IS-IT--Management
Oct 6, 2003
3
SG
Dear guys,

I'm using rattle javascript for my webbie. But to my astonishment, this script seem to work in windows but not mac.

Can anyone pls assist me in solving this problem and explain in brief why does some javascripts work only in window but not mac, vice versa.

The script as follows:

<head>

<style>
.shakeimage{
position:relative
}
</style>
<script language=&quot;JavaScript1.2&quot;>

/*
Shake image script (onMouseover)-
? Dynamic Drive (For full source code, usage terms, and 100's more DHTML scripts, visit */

//configure shake degree (where larger # equals greater shake)
var rector=3

///////DONE EDITTING///////////
var stopit=0
var a=1

function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}

function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector
}
else{
shake.style.left=parseInt(shake.style.left)-rector
}
if (a<4)
a++
else
a=1
setTimeout(&quot;rattleimage()&quot;,50)
}

function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}

</script>

</head>

<body>

<a href=&quot;Furryablum.htm&quot; target=&quot;bodyframe&quot;><img src=&quot;LCimage/Lcbutton2.jpg&quot; border=&quot;0&quot;, class=&quot;shakeimage&quot; onMouseOver=&quot;init(this);rattleimage()&quot; onMouseOut=&quot;stoprattle(this);top.focus()&quot; onClick=&quot;top.focus()&quot;></a>

</body>
 
Are the browser's kicking up any errors???
What are they??

2b||!2b
 
Dear Lrnmore,

Nope. Not an error was found.
My friend is using a mac and she told me that she could'nt see the rattle button (shaking button).

It is, however, most of my windows user's friends are able to see the rattle button/images.

Why is this so? Mac and windows constructed differently?
 
Yeah, there are some big differences between IE/mac and IE/windows.
 
Well, you might try moving your mouse events into
the <a> tag like this:

<a href=&quot;Furryablum.htm&quot; target=&quot;bodyframe&quot; class=&quot;shakeimage&quot;
onMouseOver=&quot;init(this);rattleimage()&quot; onMouseOut=&quot;stoprattle(this);top.focus()&quot;>
<img src=&quot;../Graphics/bullets/bluebullet1b.gif&quot; border=&quot;0&quot;
onClick=&quot;top.focus()&quot;></a>
</body>

Tested this in IE6 & NN7.
Probably want to specify image dimensions in final.

2b||!2b
 
You'll want to have a look at good article on the subject.

But having had a quick look at your code, I think it is specifically excluding non IE/win (so, for example old NN won't work either?) with this line:
Code:
if ((!document.all&&!document.getElementById)||stopit==1)
          ^1                    ^2

basically if 1 and 2 above aren't TRUE, your script doesn't do the 'rattling' effect. Not sure, but perhaps IE/mac has problems with document.all?

Posting code? Wrap it with code tags: [ignore]
Code:
[/ignore][code]CodeHere
[ignore][/code][/ignore].
 
hi,
I'm on a PC at work, so I can't test your code at the moment, but I use a Mac at home, so I'll try some things and let you know.
I don't see anything in your code that IE5Mac (latest available for that platform) can't handle; you are really just moving an image on the page via styles & javascript, no big deal.

What I might try at home is, first, strip the code down and get rid of the browser sniffing conditionals.
Be sure that the Mac users you are hearing from are using IE5.

Maybe change the inital style declaration to &quot;position:absolute&quot;.

The &quot;which&quot; parameter in your &quot;init()&quot; function refers to the image, not the image ID used to move things via javascript. Maybe it should be &quot;this.id&quot; either in the function or in the passed parameter in the HMTL section.

I'm not so sure about the &quot;parseInt&quot; in the function. The position value should technically be a string, but generally strings and numbers are interchangeable in this situation. Try including everything in the parenthesis or try &quot;eval&quot;.

I'll check it out at home and let you know.

sundemon
 
Thx sundemon.

I'm waiting for result of the MAC test.

God Bless.
 
hi,
your script worked fine without any tweaking on my Mac OS9 in IE4.5, IE5, and NS6 & 7. I guess it has to do with whatever other browser your user has, or the preferences for their browser.
sundemon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top