I hava some js code below,what's the data in src? how does it works?
script.src = "data:text/javascript,inc++"
details:
<script>
//Initialize the "inc" to zero.
var inc = 0;
//Get the HEAD element from the document.
var head = document.documentElement.firstChild;
//Create and initialize SCRIPT elements in a loop,
//they will execute 2 times of the "inc++" code.
for (var i = 0; i < 2; i++) {
var script = document.createElement("script");
script.src = "data:text/javascript,inc++"; // how does the data works?
head.insertBefore(script, head.firstChild);
script.onload = function () {
console.log(inc);
};
};
</script>
the src value should be setted a url,but this does not. why so?
script.src = "data:text/javascript," + inc++;"data:text/javascript,0"