JSLint “document.write can be a form of eval” - How is this so?

笑着哭i 提交于 2019-11-29 12:21:08

问题


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


回答1:


What does your browser do with this?

document.write('<script type="text/javascript">window.alert("evaled " + (1 + 2))</script>');


来源:https://stackoverflow.com/questions/5488843/jslint-document-write-can-be-a-form-of-eval-how-is-this-so

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!