/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] hover script doesnt work with safari

Hi all,

Have a site where a Javascript works on all other browsers except Safari.

Its a TD hover effect which first didnt work on ie, but when Javascript added, all works exept on Safari, and what it does is it uses the script function but changes the background color of the whole page. Could anyone please help? Personally have nihil knowledge of Javascript.

This is the code I found on the net:

var highlightbehavior=”TD”

var ns6=document.getElementById&&!document.all
var ie=document.all

function changeto(e,highlightcolor){
source=ie? event.srcElement : e.target
if (source.tagName==”TABLE”)
return
while(source.tagName!=highlightbehavior && source.tagName!=”HTML”)
source=ns6? source.parentNode : source.parentElement
if (source.style.backgroundColor!=highlightcolor&&source.id!=”ignore”)
source.style.backgroundColor=highlightcolor
}

function contains_ns6(master, slave) { //check if slave is contained by master
while (slave.parentNode)
if ((slave = slave.parentNode) == master)
return true;
return false;
}

function changeback(e,originalcolor){
if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id==”ignore”)||source.tagName==”TABLE”)
return
else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id==”ignore”))
return
if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
source.style.backgroundColor=originalcolor
}

And for each button (td) I have this:

<tr>
<td height=”20″ align=”left” valign=”middle” class=”style” onMouseover=”changeto(event, ‘#005191’)” onMouseout=”changeback(event, ‘#FFFFFF’)”><a href=”link.html”>Name</a></td>
</tr>

Please help.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@FangAug 19.2008 — onmouseover="this.style.backgroundColor='#005191';" onmouseout="this.style.backgroundColor'#FFFFFF';"
Copy linkTweet thisAlerts:
@ZeqopaaauthorAug 19.2008 — Thanks for your prompt reply, Fang.

Now the mouseOver works but mouseOut doesnt. It just leaves it to mouseOver color. The text still changes color but td remains as mentioned above.
Copy linkTweet thisAlerts:
@ZeqopaaauthorAug 19.2008 — And this applies now for FF aswell..
Copy linkTweet thisAlerts:
@FangAug 19.2008 — Typo:onmouseout="this.style.backgroundColor[COLOR="Red"]=[/COLOR]'#FFFFFF';
Copy linkTweet thisAlerts:
@ZeqopaaauthorAug 19.2008 — Cheers Fang!

Now it works! As you might have noticed, im bit of an idiot when it comes to Scripting ? I should have seen that myself....

Am very grateful of your help.
×

Success!

Help @Zeqopaa spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...