admin管理员组文章数量:1392050
I try to prevent page reload when user click a link, so I wrote :
<a href="javascript: return false">bla</a>
Or
<a href="#">bla</a>
Seriously I don't like to use #
because when user click on the link, the url on the address bar is added the symbol #, it make the url look ugly. So I prefer to use javascript: return false
but firebug show error : "return not in function", may I know how to fix the error?
I try to prevent page reload when user click a link, so I wrote :
<a href="javascript: return false">bla</a>
Or
<a href="#">bla</a>
Seriously I don't like to use #
because when user click on the link, the url on the address bar is added the symbol #, it make the url look ugly. So I prefer to use javascript: return false
but firebug show error : "return not in function", may I know how to fix the error?
- :-) not exactly. on clicking the link nothing will happen then why he need the href!!! i was inspired by sprynos answer :-) – zod Commented Jun 1, 2011 at 1:15
- lol. Very creative, but I need onclick attribute. – zac1987 Commented Jun 1, 2011 at 1:25
3 Answers
Reset to default 6See this discussion: Which "href" value should I use for JavaScript links, "#" or "javascript:void(0)"?
Do not use href="#"
. If it has to be, either use "javascript:;"
or "javascript:void(0);"
Try using this instead:
<a href="javascript:;">bla</a>
Hope that helps.
Look at this (jsfiddle here):
<a href="http://www.google./" onclick="return false;">click me</a>
However, you should avoid using inline JavaScript. The JS in one place, separated from the code, has higher maintainability.
本文标签: javascriptHow to fix quotreturn not in functionquot error that shown on firebugStack Overflow
版权声明:本文标题:javascript - How to fix "return not in function" error that shown on firebug? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744782688a2624807.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论