html - 海豚正在阅读 noscript 部分

标签 html css noscript dolphin-browser

Dolphin 浏览器和默认 Android 浏览器正在读取 <noscript>即使在这些浏览器中打开了 javascript,我页面头部的部分。这会导致这些页面的内容无法呈现。

在头部,我链接到一个 css 样式表,当在浏览器中关闭 javascript 时,该样式表将页面上 div 内的任何内容设置为无显示。它通过驻留在一个非脚本元素中来实现这一点,因此只有在没有 javascript 的情况下才会读取样式表。

这适用于我测试过的所有台式机/笔记本电脑浏览器(未在我无权访问的 mac 上测试)。它适用于 Android 上的 Firefox 和 Opera。我只有 cyanogenmod 7,所以没有适合我的谷歌浏览器。

但是,当涉及到 Dolphin 和默认的 Android 浏览器时,它们会读取位于 noscript 部分的 css 样式表,并且几乎整个页面/网站都不会在这些浏览器中呈现。

我已经证明这是通过从头部部分删除样式表链接而发生的事情,并且页面在这些浏览器中正确呈现。

有没有办法让这些浏览器尊重头部部分的 noscript 标签?

更新:这是使用 HTML5 - 头部无脚本是允许的:http://www.w3.org/TR/html5/the-noscript-element.html#the-noscript-element

<!DOCTYPE html>
<html>
<head>
        <noscript>
            <link href="${facesContext.externalContext.requestContextPath}/css/no_javascript.css" rel="stylesheet" type="text/css" />
            <!-- this link is being read even if javascript in enabled in dolphin -->
        </noscript>

</head>
<body>
    <noscript>
        stuff in this noscript element works correctly
    </noscript>

    <div class="no_javascript_disapear">

        page full of stuff not being rendered because 
        dolphin browser is not respecting the noscript 
        tags in the head.

    </div>
</body>
</html>

// css in the noscript tag:
.no_javascript_disapear {display:none;}

最佳答案

或许您可以使用 javascript 删除该样式表?

阅读此问题以了解如何 Access Contents of <noscript> with Javascript


否则,您可以在非 js 样式表中添加标题:

<link title="noJsStylesheet"  href="....css" rel="stylesheet" type="text/css" />

然后使用这个函数来删除它:

for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("title") == 'noJsStylesheet') a.disabled = true;
}

但我真的不确定它是否适用于这个特定的 Dolphin 版本。

关于html - 海豚正在阅读 noscript 部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12778166/

相关文章:

html - CSS & SASS 导航问题

jquery - 使用 jQuery 从中间缩放图像

html - 如何在不覆盖基本 css 模板的情况下扩展 css (Python-Flask)

CSS/SCSS : Is there a way to 'reset' a property to that set in a previous class?

javascript - 在 Ajax 中使用 noscript 标签

javascript - 如果禁用了 javascript,如何在任何 X/HTML 元素上提供 css 样式?

javascript - 是否有与 <noscript> 相反的 HTML?

javascript - 在我的网站上检测恶意软件添加的广告

javascript - 无法将 div 的显示样式设置为在事件监听器中阻塞

javascript - jquery.fullPage.js 如何在不影响部分滚动的情况下在 div 中启用滚动