Jump to content

How to test to see if Javascript is turned off?


nevynev

Recommended Posts

Hi there,

 

I know I should code a side to allow non javascript users to be able to use a site but Im in a rush to build a site.

 

Could someone write me a bit of code which will test to see if a user has javascript off and if so redirects the to e.g. howtoturnonjavascript.php ?

 

Incedentally - what percentage of users accessing a social networking site are likely to have Javascript turned off?

 

Thanks

NevyNev

Actually, you can test for JavaScript in the browser (not server-side)

<html>
<body>
<script type='text/javascript'>
  window.location.href='javascriptEnabled.html';
</script>
<noscript>
  <meta HTTP-EQUIV="REFRESH" content="0; url=javascriptNotEnabled.html">
</noscript>
</body>
</html>

 

http://www.w3schools.com/browsers/browsers_stats.asp (w3schools) reports that in January, 94% of visitors to their site had JavaScript enabled. That figure might be a bit off, since it's a web developers' website, but I figure its close... maybe 90% of typical web users have JS.

 

Hope that helps.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.