搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

Learn More

HTML Link (<a href)- wrong behaviour

  • 2 回覆
  • 3 有這個問題
  • 15 次檢視
  • 最近回覆由 goncalofbg

more options

Hello,

This simple code

<a href="javascript:$('.div-feedback').fadeIn();">

doesn't work in my newest version of firefox 29.0.1. it works on chrome just fine as it should.

rather than interpret as javascript, it reads as an url (opens the page "javascript:$('.div-feedback').fadeIn();" which is wrong of course)

Do you have an idea why?

Thank you Gonçalo

Hello, This simple code <a href="javascript:$('.div-feedback').fadeIn();"> doesn't work in my newest version of firefox 29.0.1. it works on chrome just fine as it should. rather than interpret as javascript, it reads as an url (opens the page "javascript:$('.div-feedback').fadeIn();" which is wrong of course) Do you have an idea why? Thank you Gonçalo

被選擇的解決方法

Actually, the href attribute is supposed to direct the browser to a new URL, etc., not run a script. Instead, use the onclick event attribute:

   <a onclick = “$('.div-feedback').fadeIn();”></a>.

Happy coding!

從原來的回覆中察看解決方案 👍 0

所有回覆 (2)

more options

選擇的解決方法

Actually, the href attribute is supposed to direct the browser to a new URL, etc., not run a script. Instead, use the onclick event attribute:

   <a onclick = “$('.div-feedback').fadeIn();”></a>.

Happy coding!

由 Epicaleb 於 修改

more options

Fair enough.

Thanks