內容,我有以下的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固定 –