Script and Noscript Element in HTML
The Script element is used in the HTML file for using the JavaScript in the code. JavaScript allows us to enhance the functionality of the HTML file. The Noscript element is used to display the
alternate text on the browser that does not support scripts.
An HTML file named: "SCRIPT_NOSCRIPT.html", Let's understand the use of Script
and Noscript elements in HTML file.
Write the Code :
- <!DOCTYPEHTML>
- <html>
- <head>
- <script type="text/javascript">
- document.write("Welcome in HTML World")
- </script>
- </head>
- <body>
- <noscript>
- JavaScript is disabled or not to your Browser.
- </noscript>
- </body>
- </html>
Here the Scripted text is “Welcome in HTML world”, If our Web browser supports
JavaScript it will show Welcome in HTML World otherwise it will display
Noscript Content.
Output When Browser JavaScript Supporting:
Now Disable the Java Script from your Browser(Google Chrome):
Steps for Disabling JavaScript from your
Browser:
- Click on Customize and control Google
Chrome button at the top corner and select the “Setting” option from the
context menu.
After Clicking on setting option:
- Select the Show advance Setting then
Click on Privacy >> Content Setting :
- Select the Do Not allow any Site to Run
JavaScript radio button in the JavaScript section to disable the JavaScript.
- Close the Setting page and Open the
SCRIPT_NOSCRIPT.HTML file, Now it will show the content written in Noscript
Element. "JavaScript is disabled or not to your Browser.