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>
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
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With