Mozilla Support में खोजें

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Javascript doesn't work even when about:config | javascriptenabled is checked to verify it is enabled.

  • 3 प्रत्युत्तर
  • 3
  • 3 views
  • के द्वारा अंतिम प्रतियुतर PostalMike

more options

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)

I've looked over forum issues similar to this and they're just too complex to be right. Chrome displays this simple code: <pre><nowiki><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></nowiki></pre> 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 <sup>edit: tried to fix the styling - that didn't work. for the code sample please see https://pastebin.mozilla.org/8838794 (philipp)</sup>

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.

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)

more options

This forum software mangles html code that is put in the Reply box.

You can post HTML code to pastebin. http://pastebin.mozilla.org/

more options

चयनित समाधान

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.

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'" />
more options

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!