内容,我有以下的html:无法写入里面的iframe
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Scrape test</title>
</head>
<body>
<div id="beatles">
<div>
<iframe id="gozujinsama"></iframe>
</div>
</div>
<script type="text/javascript">
var ifrm = document.getElementById('gozujinsama');
var doc = ifrm.contentWindow || ifrm.contentDocument.document || ifrm.contentDocument;
doc.open();
doc.write("<DOCTYPE html><html><body><a href=\"http://google.com\"><img src=\"\"/></a></body></html>");
doc.close();
</script>
</body>
</html>
我尝试是模拟各种广告脚本怎么写的iframe中的HTML内容。然后我试图访问它,然后我从我的JavaScript控制台得到以下错误:
TypeError: doc.write is not a function
你知道为什么吗?
@DimitriosDesyllas固定 –