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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.