gli Posted June 27, 2008 Share Posted June 27, 2008 Why my javascript code is not working in Mozilla Firefox ( not in IE) when i add doctype 'xhtml' to my code? Thanks. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" rev="stylesheet" href="styles.css" /> <script type="text/javascript" src="skript.js"></script> <style type="text/css"> <!-- #apDiv1 { position:absolute; left:205px; top:16px; width:200px; height:100px; z-index:1; color: red; } --> </style> </head> <body onload="goRightTime(), fadeOutTime()"> <div id="apDiv1"><a href='one.html'>this is one</a></div> <a id="linkleft" href="#" onclick="goLeft(), stopInterval(), fadeout(), fadeout2()"></a> <div id="boxLeft"><img height="80" width="100" id="imgLeft" src="images/0.gif" alt="imgleft"></img></div> <div id="boxMid"><img height="100" width="200" id="imgMid" src="images/one.gif" alt="imgmid"></img></div> <div id="boxRight"><img height="80" width="100" id="imgRight" src="images/two.gif" alt="imgright"></img></div> <a id="linkright" href="#" onclick="goRight(), stopInterval()"></a> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/112213-solved-adding-doctype-xhtml-javascript-not-working/ Share on other sites More sharing options...
gli Posted June 30, 2008 Author Share Posted June 30, 2008 :'( somebody, please Quote Link to comment https://forums.phpfreaks.com/topic/112213-solved-adding-doctype-xhtml-javascript-not-working/#findComment-577988 Share on other sites More sharing options...
haku Posted June 30, 2008 Share Posted June 30, 2008 Without at least posting your javascript, and preferably posting a link, it's almost impossible to say what is wrong. Try downloading firefox and the firebug plugin. The firebug plugin has a great javascript error console that will tell you what the errors are in your script so that you can fix them. Quote Link to comment https://forums.phpfreaks.com/topic/112213-solved-adding-doctype-xhtml-javascript-not-working/#findComment-578118 Share on other sites More sharing options...
gli Posted July 1, 2008 Author Share Posted July 1, 2008 Ok Thanks! But fireBug says: "Error: imgLeft is not defined" var myPix = new Array("images/0.gif","images/one.png","images/two.gif","images/three.gif","images/four.gif"); function goRight() { myPix.push(myPix.shift()); imgLeft.src = myPix[0]; imgMid.src = myPix[1] imgRight.src = myPix[2]; } Quote Link to comment https://forums.phpfreaks.com/topic/112213-solved-adding-doctype-xhtml-javascript-not-working/#findComment-579070 Share on other sites More sharing options...
lemmin Posted July 1, 2008 Share Posted July 1, 2008 Try boxLeft.imgLeft.src and so on. Quote Link to comment https://forums.phpfreaks.com/topic/112213-solved-adding-doctype-xhtml-javascript-not-working/#findComment-579196 Share on other sites More sharing options...
gli Posted July 1, 2008 Author Share Posted July 1, 2008 Error: boxLeft is not defined Quote Link to comment https://forums.phpfreaks.com/topic/112213-solved-adding-doctype-xhtml-javascript-not-working/#findComment-579214 Share on other sites More sharing options...
lemmin Posted July 1, 2008 Share Posted July 1, 2008 Interesting. I don't use Firefox often so I'm not sure what it requires, but you can try document.boxLeft.imgLeft.src or even document.getElementById("boxLeft").imgLeft.src. If the first doesn't work, the second should. Quote Link to comment https://forums.phpfreaks.com/topic/112213-solved-adding-doctype-xhtml-javascript-not-working/#findComment-579244 Share on other sites More sharing options...
haku Posted July 1, 2008 Share Posted July 1, 2008 you can try document.boxLeft.imgLeft.src This javascript is dependent on the name attribute, not the id attribute. It's also older javascript and doesn't follow the DOM model, so it's kind of outdated. Your second one would work though. That being said, this code will target the image directly: document.getElementById("imgLeft").src = "path/to/source" repeat for imgMid and imgRight Quote Link to comment https://forums.phpfreaks.com/topic/112213-solved-adding-doctype-xhtml-javascript-not-working/#findComment-579246 Share on other sites More sharing options...
gli Posted July 1, 2008 Author Share Posted July 1, 2008 document.getElementBy.... omg it's so logic, why i didn't think about this Big thanks !!! :) Quote Link to comment https://forums.phpfreaks.com/topic/112213-solved-adding-doctype-xhtml-javascript-not-working/#findComment-579273 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.