tag, an important tag that has been ignored. How much do you know about the definition and specific usage of the html noscript tag? What is the noscript tag used for? This article will tell you the definition and specific usage examples of html noscript tag. Let’s take a look together
html The definition and usage of the noscript tag:
The noscript element is used to define Alternative content (text) when the script is not executed.
This tag can be used by browsers that recognize the <script> tag but cannot support the script within it. </script>
HTML Tag example:
##JavaScript
<body>
...
...
<script type="text/javascript">
<!--
document.write("Hello World!")
//-->
</script>
<noscript>Your browser does not support JavaScript!</noscript>
...
...
</body> Copy after login
VBScript
<body>
...
...
<script type="text/vbscript">
<!--
document.write("Hello World!")
'-->
</script>
<noscript>Your browser does not support VBScript!</noscript>
...
...
</body> Copy after login
html The meaning and explanation of the noscript tag:
html The noscript tag is a quite old tag. The original purpose of its introduction was to help the old Smooth upgrade of browsers because early browsers did not support JavaScript. The noscript tag displays alternative content in browsers that do not support JavaScript. This element can contain any HTML element. The usage of this tag is also very simple:
<noscript>
<p>本页面需要浏览器支持(启用)JavaScript</p>
</noscript> Copy after login
However, by now, browsers that do not support Javascript should no longer appear, but users may also have disabled Javascript for various reasons. Such as saving traffic, extending battery life, or not wanting your privacy to be leaked by various statistics/tracking scripts. There are also quite a few users who have installed browser extensions like NoScript to prevent the browser from running Javascript.
Although the website cannot force users to enable Javascript in their browsers, it can prompt users that their browsers have disabled scripts to achieve a better user experience.
Recommended related articles: 1. The difference between script tag and noscript tag in html
Related video recommendations:
1. Dugu Jiujian (1)_HTML5 video tutorial For example, Fackbook prompts like this:
html The content in the elements in the noscript tag will only be displayed under the following circumstances:
The browser does not support scripts
The browser supports scripts, but scripts are disabled
If any of the above conditions are met, the browser will display the content in noscript. In other cases, the browser will not render the content in noscript.
Using the noscript tag can only convey a message to website users, that is, if Javascript is not enabled, the content and effects of the web page may not be fully rendered. But if some users don't know how to turn on Javascript, such prompt information will not be of any practical help to them. Therefore, we should still consider how to make such unconventional situations affect the user's browsing experience as little as possible without the support of Javascript (or HTML5, or other dependencies) at the beginning of website design.
Usage of noscript in HTML:
The noscript element is used to define alternative content (text) when the script is not executed. This tag can be used to identify the <script> element to define alternative content (text) when the script is not executed. tag but cannot support the script within it. If the browser supports scripts, the content of the noscript tag will not be displayed. <p></p><p>noscript tag usage example: <strong></strong><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:html;toolbar:false"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><meta http-equiv="Content-Language" content="zh-cn" />
</head>
<body>
<script type="text/javascript">
<!--document.write("如果显示了这段文字,那么您的浏览器支持 JavaScript!")//--></script>
<noscript>No JavaScript support!</noscript>
<p>不支持 JavaScript 的浏览器将显示 noscript 元素中的文本。</p>
</body>
</html></pre><div class="contentsignin">Copy after login</div></div></p>Tips and Notes: <p></p>Note: If the browser supports scripts, it will not display the noscript element text in . <p></p>Note: Browsers that cannot recognize the <script> tag will display the content of the tag on the page. To prevent browsers from doing this, you should hide the script in comment tags. Older browsers (that don't recognize <script> tags) ignore comments and thus don't write the content of the tag to the page, while newer browsers know how to execute these scripts even if they are surrounded by comment tags. ! <p>【Editor's related articles】<p><p>html What does the col tag mean? Introduction to the usage examples of html col tag<a href="//m.sbmmt.com/div-tutorial-408815.html" target="_blank"><br/><p>Introduction to the style of html5 table tag (an example of html5 table css centering is attached)<a href="//m.sbmmt.com/html5-tutorial-408816.html" target="_blank"><br/></script>
The above is the detailed content of What does the html noscript tag mean? How much do you know about the use of noscript tags?. For more information, please follow other related articles on the PHP Chinese website!