JSLint“document.write可以是eval的一种形式”。 - 这是怎么回事? [英] JSLint "document.write can be a form of eval" - How is this so?

查看:138
本文介绍了JSLint“document.write可以是eval的一种形式”。 - 这是怎么回事?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JSLint中遇到过这条消息......

I've come across this message in JSLint...


document.write可以是eval的一种形式。

document.write can be a form of eval.

并且想知道具体如何?

JSLint说明页面说明:


eval函数...提供对JavaScript
编译器的访问。这有时是必要的,
,但在大多数情况下它表示
存在非常糟糕的编码....

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....



<那么, document.write 如何提供对JavaScript编译器的访问呢?

So, how does document.write "provide access to the JavaScript compiler" then?

谢谢

推荐答案

您的浏览器对此做了什么?

What does your browser do with this?

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

这篇关于JSLint“document.write可以是eval的一种形式”。 - 这是怎么回事?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆