Jump to content

Problem with mouseover in IE


yz-s

Recommended Posts

OK Might be a NOOB question but here's my problem. In Firefox everything works like a charm, but when I open my page www.yz-s.nl in IE I get a lot of script errors, why is this? and how can I fix it?thanks a lotyz-s

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>yz-s</title><link href="yz-s.css" rel="stylesheet" type="text/css"/><script type="text/javascript">function mouseover1(){document.b1.src="homebutton_2.gif"}function mouseout1(){document.b1.src="homebutton_1.gif"}function mouseover2(){document.b2.src="aboutmebutton_2.gif"}function mouseout2(){document.b2.src="aboutmebutton_1.gif"}function mouseover3(){document.b3.src="goalbutton_2.gif"}function mouseout3(){document.b3.src="goalbutton_1.gif"}function mouseover4(){document.b4.src="picturesbutton_2.gif"}function mouseout4(){document.b4.src="picturesbutton_1.gif"}function mouseover5(){document.b5.src="agendabutton_2.gif"}function mouseout5(){document.b5.src="agendabutton_1.gif"}function mouseover6(){document.b6.src="newsbutton_2.gif"}function mouseout6(){document.b6.src="newsbutton_1.gif"}function mouseover7(){document.b7.src="onmymindbutton_2.gif"}function mouseout7(){document.b7.src="onmymindbutton_1.gif"}</script></head><body><div id="menu1"> <a href="http://www.yz-s.nl"> <img src="homebutton_1.gif" id="b1" alt="homebutton" width="120" height="35" onmouseover="mouseover1()" onmouseout="mouseout1()" /></a></div><div id="menu2"> <a href="http://www.yz-s.nl/aboutme.html"> <img src="aboutmebutton_1.gif" id="b2" alt="aboutmebutton" width="120" height="35" onmouseover="mouseover2()" onmouseout="mouseout2()" /></a></div><div id="menu3"> <a href="http://www.yz-s.nl/goal.html"> <img src="goalbutton_1.gif" id="b3" alt="goalbutton" width="120" height="35" onmouseover="mouseover3()" onmouseout="mouseout3()" /></a></div><div id="menu4"> <a href="http://www.yz-s.nl/pictures.html"> <img src="picturesbutton_1.gif" id="b4" alt="picturesbutton" width="120" height="35" onmouseover="mouseover4()" onmouseout="mouseout4()" /></a></div><div id="logo"></div><div id="logotekst">www.yz-s.nl</div><div id="sitemap"></div><div id="sitemaptekst">Home</div><div id="foto"></div><div id="agendalogo"> <a href="http://www.yz-s.nl/agenda.html"> <img src="agendabutton_1.gif" id="b5" alt="agendabutton" width="170" height="25" onmouseover="mouseover5()" onmouseout="mouseout5()" /></a></div><div id="agenda"></div><div id="agendatekst">12-12 Aura Jarig<br />24-12 Ohinya Jarig<br />25-12 Kerst<br />31-12 Mountassir jarig<br />01-01 Nieuwjaar<br /></div><div id="subscribe"></div><div id="subscribetekst">subscribe</div><div id="contact"></div><div id="contacttekst">contact</div><div id="background1"></div><div id="middlebreak"></div><div id="background2"></div><div id="underbar">contactyz.s@gmail.com</div><div id="bbb"></div><div id="blog1"> <a href="http://www.yz-s.nl/news.html"> <img src="newsbutton_1.gif" id="b6" alt="newsbutton" width="240" height="20" onmouseover="mouseover6()" onmouseout="mouseout6()" /></a></div><div id="blog2"> <a href="http://www.yz-s.nl/onmymind.html"> <img src="onmymindbutton_1.gif" id="b7" alt="onmymindbutton" width="240" height="20" onmouseover="mouseover7()" onmouseout="mouseout7()" /></a></div></body></html>
Link to comment
Share on other sites

Instead of writing an almost identical function for each img, you might try writing two functions instead. If all of your image paths end in "_1" for "off" and "_2" for on, you can do this:

function handleMouseOver(obj){	var src = obj.src;	if( src.indexOf("_1") > -1 )	{		obj.src = src.replace("_1", "_2");	}}function handleMouseOut(obj){	var src = obj.src;	if( src.indexOf("_2") > -1 )	{		obj.src = src.replace("_2", "_1");	}}

Then, to call the functions, you can do this:

<img src="theimagepath_1.gif" onmouseover="handleMouseOver(this);" onmouseout="handleMouseOut(this);" />

Check out the HTML DOM if those functions aren't making sense. Also, if you wanted, since those two function are themselves so similar, you could combine them into a single function, but I'll leave that up to you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...