我有一个脚本,例如:
<script> document.body....make something and draw many things in the browser </script>
我想在 iframe 内执行沙盒操作。 如何在 iframe 中加载这段 javascript?
我正在尝试不起作用:
document.getElementById('previewFrame').contentWindow.document.body.innerHTML = "<script language='javascript'></script>";
谢谢。
最佳答案
命名框架并执行操作
window.frames["framename"].document.write('<script>...<\/script>');
window.frames["framename"].document.close();
关于javascript - 在 iframe 中加载脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12536785/