使用 JavaScript 创建 iframe
HTML 元素的最佳做法是什么?
var iframe = document.createElement("iframe");
iframe.setAttribute("sandbox", "")
iframe.setAttribute("src", url);
我在开发Firefox插件时遇到过这个问题,但是用法和开发网页是一样的。我不使用 jQuery。
最佳答案
你可以试试 this :-
<script type="text/javascript">
function abc() {
iframe = document.createElement("IFRAME");
iframe.setAttribute("src", "http://example.com/");
iframe.style.width = "640px";
iframe.style.height = "480px";
document.body.appendChild(iframe);
}
</script>
关于javascript - 使用 JavaScript 创建 IFRAME 的最佳做法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18580811/