Noscript tag in HTML
- 24-07-2022
- Trung Minh
- 0 Comments
In this article, I will show you how to use the noscript tag in HTML, this is a very useful tag in case the browser does not support javascript.
1. What is a noscript tag?
We have already learned the script tag, right? It is used to declare where the javascript code is stored for the browser to compile.
The noscript tag, on the other hand, will create an alternative content to display to the user if the browser has disabled scripting. It sounds strange, but the truth is that most browsers support the ability to disable javascript code.
For example, you have a very important javascript file, now you will display a message to the user when they turn off javascript in the browser, because the website will not work as expected.
<noscript>Vui lòng bật tính năng biên dịch Javascript lên!</noscript>
In fact, this card is rarely used, because no user would restrict such an important feature in the process of using the web.
2. How to use the noscript . tag
For example , use the noscript tag to display a warning if the browser does not support scripts.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <h1>Học lập trình miễn phí tại web888.vn</h1> <script> document.write("web888.vn") </script> <noscript>Trình duyệt của bạn không hỗ trợ javascript!</noscript> </body> </html>
In the example above you can disable the browser's javascript, then run the program again to see the change.