我想执行另一台服务器上的 javascript 文件,并从我的 javascript 代码中获取该脚本的输出。有什么办法可以做到这一点吗? 提前致谢。
最佳答案
The file which is on another server contains document.write method. Can I get that output in my javascript variable?
仅通过覆盖 document.write
然后加载新脚本。
function capture(data) {
// do something with data
}
document.write = capture;
var script = document.createElement("script");
script.src = "http://example.com/example.js";
document.body.appendChild(script);
关于javascript - 执行另一台服务器上的脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33233686/