Sometimes websites receive visitors whose browsers either do not support JavaScript or JavaScript is disabled in their browsers. In such cases, Noscript tag is used to display an error message to the visitors, that the site requires JavaScript to display all the contents properly.
NOTE: The noscript tag needs to be placed outside the <script> </script> tags as anything between them will be considered javascript and thus javascript disabled browser will not display the Error Message/Note withing the noscript tags.
SYNTAX
| <noscript> Message </noscript> |
Example
You can Copy Paste the code below into a new htm file code view.
| <html> <head> <title> JavaScript Noscript tags</title> </head> <body> <noscript> <h3> All the contents of the page cannot be properly displayed because your browser does not support JavaScript </h3> <h4>This could be because 1. Javascript is disabled in your browser. How to enable Javascript? Click Here </h4> <h4>Cause 2- Your Browser is quite old and does not support JavaScript. We recommend Downloading Mozilla Firefox. To Download Firefox. Click Here</h4> </noscript> <p> <script type="text/javascript"> document.write("Welcome to my first page. This text is being displayed using JavaScript"); </script> </p> </body> </html> |
Test The code- Disable JavaScript
To test this code, you first need to turn off JavaScript in your Browser, otherwise normal JavaScript code will be executed and this noscript message will not be dispalyed.To disable javascript in Mozilla Firefox, go to options > Content tab and remove the check from Enable Javascript.

Result
Now View the page in a browser and the noscript message will be displayed.prev<<JavaScript Comments
Back to index of javascript
part2-->Writing your First JavaScript Code


No comments:
Post a Comment