如何从href调用javascript? [英] How to call javascript from a href?
本文介绍了如何从href调用javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
像:
< a href =< script type ='text / javascript'>脚本代码< / script> />调用JavaScript< / a>
解决方案
< a onClick = yourFunction(); return false; href =fallback.html>单向< / a>
编辑 br>从前面的评论中,我分享了给出的资源。
之前的SO Q和A's:
有趣的读法:
p>
- http://crisp.tweakblogs.net/blog/the-useless-javascript-pseudo-protocol.html
- https://developer.mozilla.org/en-US/docs/JavaScript/R eference / Statements / label
How to call javascript from a href?
like:
<a href="<script type='text/javascript'>script code</script>/">Call JavaScript</a>
解决方案
<a onClick="yourFunction(); return false;" href="fallback.html">One Way</a>
** Edit **
From the flurry of comments, I'm sharing the resources given/found.
Previous SO Q and A's:
- Do you ever need to specify 'javascript:' in an onclick? (and the IE related A's following)
- javascript function in href vs onclick
Interesting reads:
- http://crisp.tweakblogs.net/blog/the-useless-javascript-pseudo-protocol.html
- https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Statements/label
这篇关于如何从href调用javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文