代码:
var dataScript = '$("#foo").append("$ and #foo exists!")';假设我们在文档中加载了一些库(例如:$jQuery),如果我们运行以下代码
eval(dataScript); //This will work and adds a text to our current document我要:
eval(dataScript); //$ is undefined (Maybe you're in another context?)我目前使用use库http://jterrace.github.io/js.js/,但是这个库需要手动添加许多基本项,如window、document、etc ...
有一些方法可以在不与当前页面交互的情况下运行脚本当前窗口和新上下文之间也应该有通信。
+
发布于 2015-08-24 13:55:09
您可以在沙箱选项中使用Iframe,这是sandbox.asp的最佳解决方案。
https://stackoverflow.com/questions/32184085
复制相似问题