不能用document.write写入头文件

时间:2013-10-28 09:26:27

标签: javascript html

我想在没有src的情况下更改iframe的内容。所以我试试

var doc = findIframe().get(0).contentWindow.document;
    doc.open();
    doc.write(GM_getResourceText('iframe.html'));
    doc.close();

iframe.html的内容:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>iframe</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <style type="text/css">some style</style>
        <script> some script</script>
    </head>
<body>
</body>
</html>

但所有elemets而非iframe头都附加到iframe身上。我从主窗口执行脚本。如何解决?

0 个答案:

没有答案