我有一个HTML字符串
<html>
<body>Hello world</body>
</html>
我想用JavaScript将其设置为iframe。我正在尝试像这样设置HTML:
contentWindow.document.body.innerHTML
或者contentDocument.body.innerHTML
或者document.body.innerHTML
但是 IE 给出 "Access is denied." 或 "Object does not support this property or method." 或者 "Invalid final element to the action." 错误。
这是我完整的代码:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery_1.7.0.min.js"/></script>
</head>
<body>
<p>This is iframe:
<br>
<iframe id="iframe1">
<p>Your browser does not support iframes.</p>
</iframe>
</body>
</html>