gpt4 book ai didi

javascript - 使用 JavaScript 在 Internet Explorer 中插入外部 CSS

转载 作者:行者123 更新时间:2023-11-28 17:10:16 25 4
gpt4 key购买 nike

我正在尝试使用控制台将外部 CSS 加载到 Internet Explorer 中。当我编写注入(inject)代码时,它说存在语法错误。

$(document.head).append('<link rel="stylesheet" href="http://fahaduddin.com/css-new/mystyles.css">');

最佳答案

您可以使用此代码:

var element = document.createElement("link");
element.setAttribute("rel", "stylesheet");
element.setAttribute("type", "text/css");
element.setAttribute("href", "external.css");
document.getElementsByTagName("head")[0].appendChild(element);

关于javascript - 使用 JavaScript 在 Internet Explorer 中插入外部 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46439331/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com