Reputation: 30520
I've come across this message in JSLint...
document.write can be a form of eval.
and was wondering exactly how so?
The JSLint instructions page states:
The eval function...provide access to the JavaScript compiler. This is sometimes necessary, but in most cases it indicates the presence of extremely bad coding....
So, how does document.write
"provide access to the JavaScript compiler" then?
Thanks
Upvotes: 12
Views: 10539
Reputation: 283773
What does your browser do with this?
document.write('<script type="text/javascript">window.alert("evaled " + (1 + 2))</script>');
Upvotes: 14