-
Requiring JavaScript to be enabled
Posted on July 8th, 2009 1 comment
There are many JavaScript scripts in this blog, and those related with AJAX also involve the use of this language. So I thought that it would be useful to know, when implementing such scripts in a site, how to deal with users who do not have JavaScript enabled in their browsers (or rather requiring them to enable it).The following code has a very simple goal: to tell them that JavaScript is necessary to browse the page. To do this, the <noscript> tags are used: their content will only be displayed when JavaScript is disabled, or in the rare case the users browser is outdated and does not support client-side scripting.
<html> <head> <title>JavaScript required</title> </head> <body> <div id="javascript"><script type="text/javascript"> <!-- document.write('Your JavaScript is enabled!') // --> </script> <noscript> <p>You must enable JavaScript to see this page.</p></noscript> </div> </body> </html><html><head>
<title>JavaScript required</title>
</head><body>
<div id=”warning”><script type=”text/javascript”>
<!–
document.write(’Your JavaScript is enabled!’)
// –>
</script>
<noscript>
<p>You must enable JavaScript to see this page.</p></noscript>
</div>
</body></html>
One response to “Requiring JavaScript to be enabled”
-
Deepali July 31st, 2009 at 13:19
Hello Aleix,
Nice information!
Leave a reply
-


