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 Scripted text is “Welcome in HTML world”, If our Web browser supports JavaScript the it will show Welcome in HTML World otherwise it will display Noscript Content.

 

Output When Browser JavaScript Supporting:

Script-and-Noscript-Element-in-HTML-1.jpg

Now Disable the Java Script from your Browser(Google Chrome):

Steps for Disabling JavaScript from your Browser:

  1. Click on Customize and control Google Chrome button at the top corner and select the “Setting” option from the context menu.

    Script-and-Noscript-Element-in-HTML-2.jpg

    After Clicking on setting option:

    Script-and-Noscript-Element-in-HTML-3.jpg
     
  2. Select the Show advance Setting then Click on Privacy >> Content Setting :

    Script-and-Noscript-Element-in-HTML-4.jpg
     
  3. Select the Do Not allow any Site to Run JavaScript radio button in the JavaScript section to disable the JavaScript.

    Script-and-Noscript-Element-in-HTML-5.jpg
     
  4. 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.

    Script-and-Noscript-Element-in-HTML-6.jpg
Ebook Download
View all
Learn
View all
Foreantech - A complete online solution company.