我知道您可以对< a> 标记中的网址使用javascript:pseudo协议。但是,我注意到Firefox和IE都允许' javascript:'在< script> 标签。这是有效的语法吗?它是否会改变范围规则?
I know that you can use a javascript: pseudo protocol for URLs in an <a> tag. However, I've noticed that Firefox and IE will both allow 'javascript:' to precede javascript code within a <script> tag. Is this valid syntax? Does it change the scoping rules?
示例:我已经多次看到过:
Examples: I've seen this many times:
<a onclick="javascript:alert('hello world!');">Hello World!</a>但这是合法/有效的语法并且它做了什么特别的事情:
But is this legal/valid syntax and does it do anything special:
<script type="text/javascript"> javascript:alert('hello world!'); </script>推荐答案
href之外属性(它是协议说明符), name :只创建标签(例如可以使用继续或中断)。
Outside of the href attribute (where it is a protocol specifier), name: just creates a label (such as one might use with a continue or break).
更多推荐
'javascript:'前缀何时有效?
发布评论