如何包装< noscript>标记以在javascript禁用时隐藏内容 [英] How to wrap <noscript> tag to hide content when javascript disable

查看:112
本文介绍了如何包装< noscript>标记以在javascript禁用时隐藏内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我有这样的HTML代码:

Let's say, I have HTML code like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
This is content.
</body>
</html>

我想在那里添加一个<noscript>标记.这意味着,如果禁用JavaScript,它将显示为空白页面.

And I want to add a <noscript> tag there. Which means, if the JavaScript disabled, it will show as a blank page.

并且仅当禁用JavaScript时,它才会显示这是内容文本".

And only when JavaScript is disabled, it will show "This is content text".

请给我一些例子来实现.谢谢.

Please give me some examples to achieve. Thanks.

推荐答案

rahul建议的JS方法的替代方法是在<noscript>元素中显示一个div,覆盖整个页面:

An alternative to a JS approach as suggested by rahul is to display a div in the <noscript> element, covering the entire page:

<noscript>
    <div style="position: fixed; top: 0px; left: 0px; z-index: 3000; 
                height: 100%; width: 100%; background-color: #FFFFFF">
        <p style="margin-left: 10px">JavaScript is not enabled.</p>
    </div>
</noscript>

这篇关于如何包装&lt; noscript&gt;标记以在javascript禁用时隐藏内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆