jQuery 和 IE8 中的 .append() 出现停止加载问题

发布于 2024-10-09 18:32:25 字数 329 浏览 0 评论 0原文

我正在开发一个网站,该网站根据网络浏览器的当前尺寸提取不同的样式表以供使用。我编写了以下代码行将样式表添加到 HTML:

$("head").append("<link href=\"/tta/front_page-lg.css\" rel=\"stylesheet\" type=\"text/css\">");

现在样式表加载正常,但在 IE8 中,favicon 或 IE 图标保持在“正在加载”状态或蓝色环(如果这是更清晰的描述)。

我想知道是否有另一种方式来编写我的代码,以便浏览器不会停留在“正在加载”状态。

提前致谢。

I am working on a site that pulls a different stylesheet for use based on the current dimensions of the web browser. I wrote the following line of code to add the stylesheet to the HTML:

$("head").append("<link href=\"/tta/front_page-lg.css\" rel=\"stylesheet\" type=\"text/css\">");

Now the stylesheet loads alright, but in IE8, the favicon or IE icon stays in the 'loading' state or the blue ring if that is a clearer description.

I was wanting to know if there was another way of writing my code so that the browser would not stay in the "Loading" state.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岛歌少女 2024-10-16 18:32:25

在 head 中添加所有 CSS 样式表并创建一个 body 类不是更好吗?像这样:

<html>
<head>
    <link href="stylesheet.css" media="all" type="text/css" />
    <script src="jquery.js" type="text/javascript"></script>
</head>
<body id="useStyleSheetOne">
    <a id="test" href="#">I;m a link</a>
    <script type="text/javascript">
        $(document).ready(function() {
            $('#test').click(function() {
                $('body').removeClass('useStyleSheetOne').addClass('useStyleSheetTwo');
            })
        });
    </script>
</body>

StyleSheet

useStyleSheetOne a {

color: red;
font-size: 12px;

}

useStyleSheetTwo a {

color: blue;
font-size: 32px;

}

好吧,我的第二篇文章,所以我无法在代码部分中获取样式表代码:S..对于样式表one和two来说,是#。

格茨·斯文

Is it not just better to add just all CSS stylesheets in the head and make a body class? like so:

<html>
<head>
    <link href="stylesheet.css" media="all" type="text/css" />
    <script src="jquery.js" type="text/javascript"></script>
</head>
<body id="useStyleSheetOne">
    <a id="test" href="#">I;m a link</a>
    <script type="text/javascript">
        $(document).ready(function() {
            $('#test').click(function() {
                $('body').removeClass('useStyleSheetOne').addClass('useStyleSheetTwo');
            })
        });
    </script>
</body>

StyleSheet

useStyleSheetOne a {

color: red;
font-size: 12px;

}

useStyleSheetTwo a {

color: blue;
font-size: 32px;

}

Ok my second post so i can't get the stylesheet code in the code section :S.. For the stylesheetone and two is a #.

Grtz Sven

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文