Wednesday 19 October 2016

javascript - Why does the call to this jQuery function fail in Firefox?



I have the following line of code in a link on my webpage:







This produces a link that should pop open a hidden form. It works on Safari, but in Firefox, I just get an almost-empty page with nothing but the following text:



[object Object]


I'm sure this has something to do with the value returned by the jQuery function, but I'm not sure how to fix the call to the JavaScript function so it works in Firefox, too.


Answer



For the love of...





....


[Comment]



Please, don't embed JavaScript like you just did in the HTML.



If you embed JavaScript in HTML like that, you :




  1. Make messy code.


  2. Have weird problems like you just did with hacks to get around it

  3. Users trying to middle click links will get sent nowhere.

  4. Maintaining the executable part of your code interspersed in page links will end in failure.

  5. Don't gracefully degrade when users don't have javascript

  6. Become problematic when you start needing to do stuff like store quotes more than 2 layers deep.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...