How many Different ways to invoke JS inside a html Document?
ecmascript-5, javascript
Solution
There's actually quite a lot of ways to execute Javascript in HTML, all varying across browsers and platforms.
A lot of them (but not all) are listed in this infamous XSS cheatsheet.
Among less obscure ones, there are these:
<img src="javascript:...">
<body background="javascript:...">
<style>BODY{-moz-binding:url("...")}</style>
<META HTTP-EQUIV="refresh" CONTENT="0;url=javascript:...">
...and so on.
Problem
So far I know, 4 different ways to define & invoke JavaScript in webpage 1.inline JS ``` <script type='text/javascript'> ... </script> ``` 2.External JS ``` <script src="someURL"></script> ``` 3.Event hander JS: ``` <input type="button" onclick="...javascript..." ``` 4.JavaScript:URL ``` <a href="javascript: ...JS CODE...">js</a> ``` Is there any other ways JS can be inserted in a webpage ? Has it (how many ways) been defined in any standard Specification? Is there any difference in the execution context of JavaScript among the mentioned 4 different ways?