HTML noscript

 The function of HTML noscript is used to determine the alternative to be displayed when the browser does not support HTML script . The most common way to display is the prompt text. For example, when there are many JavaScript special effects in the webpage that need to be displayed, but the user-side browsing Browser (Browser) can’t support or recognize, it is very likely that special effects will fail. At this time, the web page can tell the user that his browser does not support website special effects through the <noscript> tag. For older browsers, There are also tips when writing scripts, which will be mentioned in the example.


HTML noscript basic syntax

<noscript> ... the content to be displayed... </noscript>


The standard noscript tag should start with <noscript> and end with </noscript>. There is no need to use alert or document.write to display the content in the middle. Just write the text directly in it. The function of noscript is similar to HTML img. The meaning of the alt text in the image tag .

HTML noscript example
<script type="text/javascript">
<!--
document.write('Your browser supports this script');
-->
</script>
<noscript>Your browser does not support this script</script >
When the user's browser can recognize this script, it will display "Your browser supports this script", and if it cannot recognize it, it will display "Your browser does not support this script". This effect is all because of the <noscript > Function, please note that JavaScript annotations are used between <script type="text/javascript"> and </script> . This is the trick mentioned at the beginning of this article. When the browser used by the client is very In the old days, script applications could not be supported at all, but at least the comments can be judged and the content of the comments can be ignored, otherwise the entire script will become a string and appear on the screen. Annotations can be added to avoid this situation. Because the new browser can recognize the script, although the content of the script is marked with annotations at the beginning and the end, it can still be executed, and the individual annotations in the script are still valid.

Further reading
  • HTML script

Post a Comment

0 Comments