Why javascript:void(0) is not working in Firefox

拜拜、爱过 提交于 2019-12-31 05:27:31

问题


Why is this simple link example not working in Firefox? It is working in IE and Chrome.
js fiddle sample
I am using windows XP. My Firefox version is 16.0.


回答1:


My research for getItems() showed what in some situations this function is defined as native function. I don't know why. To avoid this trouble try to rename function getItems.

http://jsfiddle.net/u6bKr/3/

UPDATE:

As specified in comment by Boris Zbarsky this trouble can be also avoided when adding window. before getItems() (e.g. window.getItems()).




回答2:


Your fiddle sample shouldn't work in any browser because you've defined the getItems() method inside the onload handler that is the jsfiddle default (as set on the left-hand side) which in turn means that it is not in scope from the inline onclick="getItems()" attribute.

It works in FF if you fix that by selecting no wrap (head) instead of onLoad, thus making your function global: http://jsfiddle.net/u6bKr/1/

(Note that this has nothing to do with href="javascript:void(0);")



来源:https://stackoverflow.com/questions/12401524/why-javascriptvoid0-is-not-working-in-firefox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!