noscript Element

Description

The noscript element allows you to display content to users who have disabled JavaScript or who are using a browser that doesn't support it.

The noscript element displays content and explains that they can't use your site or page unless they enable JavaScript.

Example

The following code shows the noscript element set up to display a simple message.


<!DOCTYPE HTML>
<html>
<head>
<script defer src="simple2.js"></script>
<noscript>
    <h1>Javascript is required!</h1>
    <p>You  cannot use  this page  without Javascript</p>
</noscript>
</head>
<body>
   <p>This is a test.</p>
   <a href="http://java2s.com">Visit  java2s.com</a>
</body>
</html>

The remainder of the page is processed as normal, and the content elements are still displayed.

You can add multiple noscript elements to a page.

Example 2

Youc can also redirect the user's browser to a different URL if it doesn't support JavaScript by placing a meta element inside the noscript element.


<!DOCTYPE HTML>
<html>
<head>
<script defer src="simple2.js"></script>
<noscript>
   <meta http-equiv="refresh"  content="0; http://www.java2s.com"/>
</noscript>
</head>
<body>
   <p>This is a test.</p>
   <a href="http://java2s.com">java2s.com</a>
</body>
</html>

This will redirect the user to the www.java2s.com site when a browser that doesn't support JavaScript, or that has JavaScript disabled.





















Home »
  HTML CSS »
    HTML »




HTML Introduction
HTML Document
HTML Section
HTML Group Content
HTML Text Marker
HTML Table
HTML Form
HTML Embed