Javascript doesn't work even when about:config | javascriptenabled is checked to verify it is enabled.
I've looked over forum issues similar to this and they're just too complex to be right.
Chrome displays this simple code:
<body > <h1>Simple Hover</h1> <img id="home" name="img_home" src="hover/home_default.png" alt="Home" onmouseover="window.document.img_home.src = 'home_over.png'" onmouseout="window.document.img_home.src='home_default.png'" /> </body>
Firefox doesn't. Verified javascript is enabled and it is.
This is for a self-pace class so it's no urgency ... but ... assuming it was my code I deleted all my lessons involving hover and re-started, only to find the error continued and THEN I tried Chrome, LOL.
I'm on version 38.0.5, on Windows 7. In simple terms, how do I fix this?
Thanks,
Mike
edit: tried to fix the styling - that didn't work. for the code sample please see https://pastebin.mozilla.org/8838794 (philipp)
cor-el द्वारा
चुने गए समाधान
I don't think that you can use window.document.img_home.src to set the source attribute of an image. In Firefox you need to use document.getElementById or one of the other possible getElement(s) functions.
- https://developer.mozilla.org/Web/API/Document/getElementById
- https://developer.mozilla.org/Web/API/Document/getElementsByName
- https://developer.mozilla.org/Web/API/Document/querySelector
As you are referring to the current element, easiest would be to use the this' selector.
<img id="home" name="img_home" src="hover/home_default.png" alt="Home" onmouseover="this.src = 'home_over.png'" onmouseout="this.src='home_default.png'" />संदर्भ में यह जवाब पढ़ें 👍 2
All Replies (3)
This forum software mangles html code that is put in the Reply box.
You can post HTML code to pastebin. http://pastebin.mozilla.org/
चयनित समाधान
I don't think that you can use window.document.img_home.src to set the source attribute of an image. In Firefox you need to use document.getElementById or one of the other possible getElement(s) functions.
- https://developer.mozilla.org/Web/API/Document/getElementById
- https://developer.mozilla.org/Web/API/Document/getElementsByName
- https://developer.mozilla.org/Web/API/Document/querySelector
As you are referring to the current element, easiest would be to use the this' selector.
<img id="home" name="img_home" src="hover/home_default.png" alt="Home" onmouseover="this.src = 'home_over.png'" onmouseout="this.src='home_default.png'" />
PostalMike said
I've looked over forum issues similar to this and they're just too complex to be right. Chrome displays this simple code:<body > <h1>Simple Hover</h1> <img id="home" name="img_home" src="hover/home_default.png" alt="Home" onmouseover="window.document.img_home.src = 'home_over.png'" onmouseout="window.document.img_home.src='home_default.png'" /> </body>Firefox doesn't. Verified javascript is enabled and it is.
This is for a self-pace class so it's no urgency ... but ... assuming it was my code I deleted all my lessons involving hover and re-started, only to find the error continued and THEN I tried Chrome, LOL.
I'm on version 38.0.5, on Windows 7. In simple terms, how do I fix this?
Thanks,
Mike
edit: tried to fix the styling - that didn't work. for the code sample please see https://pastebin.mozilla.org/8838794 (philipp)
Makes sense. The reason for JavaScript libraries is to eliminate having to write compatible code for different browsers. Looks like using jQuery, Ext, etc. is a requirement here.
Thanks!