【问题标题】:How to add a css file to an open window如何将css文件添加到打开的窗口
【发布时间】:2016-08-12 15:26:21
【问题描述】:

我正在尝试打开一个新的 html 窗口并将其链接到外部 css 文件..

var myWindow = window.open("", "MsgWindow");

var fileref=document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", 'kamusi_ext-v1.css');

myWindow.document.head.appendChild(fileref);

但是我得到了这个错误:

script.js:70 Uncaught SecurityError: Blocked a frame with origin "null" from access a frame with origin "null".协议、域和端口必须匹配。

在 Firefox 上运行相同的脚本时,我没有收到此错误,但没有应用 css!

【问题讨论】:

标签: javascript jquery html css w3c


【解决方案1】:

它似乎在这里工作:|

我认为这与跨域有关。谷歌搜索你提供的错误会给你一个提示。祝你好运!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-07-14
    • 1970-01-01
    • 2021-10-24
    • 1970-01-01
    • 2019-01-27
    • 2015-04-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多