Sunday, 18 July 2021

When is the 'javascript:' prefix valid syntax?

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>


from When is the 'javascript:' prefix valid syntax?

No comments:

Post a Comment