Prohledat stránky podpory

Vyhněte se podvodům. Za účelem poskytnutí podpory vás nikdy nežádáme, abyste zavolali nebo poslali SMS na nějaké telefonní číslo nebo abyste sdělili své osobní údaje. Jakékoliv podezřelé chování nám prosím nahlaste pomocí odkazu „Nahlásit zneužití“.

Learn More

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

  • 3 odpovědi
  • 3 mají tento problém
  • 4 zobrazení
  • Poslední odpověď od 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>

Upravil uživatel cor-el dne

Zvolené řešení

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'" />
Přečíst dotaz v kontextu 👍 2

Všechny odpovědi (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

Zvolené řešení

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!