By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,793 Members | 1,257 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,793 IT Pros & Developers. It's quick & easy.

Block if javascript is disabled

chathura86
100+
P: 227
hi

Is there a way to block users from accessing my site if
the javascript is disabled (or not supported) in the browser

it is ok to block them from server if necessary. i'm using PHP
as the serverside lang.

any how i want to keep non-javasctipt users out

regards

chathura bamunusinghe
Sep 27 '08 #1
Share this Question
Share on Google+
4 Replies


acoder
Expert Mod 15k+
P: 16,027
Instead of trying to block the user, use the <noscript> tag to display content or a message when JavaScript is disabled.
Sep 27 '08 #2

chathura86
100+
P: 227
well <nosctipt> will only inform the user that his browser does not support
javascript and the page will be displayed on the screen

i'm looking for a way to block the user from viewing the page if his browser
does not support javascript

i'm not sure whether it is posible to do it

thanks for the help

regards

chathura bamunusinghe
Sep 27 '08 #3

acoder
Expert Mod 15k+
P: 16,027
There's no point in trying to block the user and you can't check JavaScript settings on the server.

The noscript tag doesn't need to display that JavaScript is disabled. It could have something useful instead. Why do you want to block the page anyway?
Sep 27 '08 #4

rnd me
Expert 100+
P: 427
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>JavaScript Required!</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6.  
  7. <style type='text/css'>
  8.     body { display    : none; }
  9. </style>
  10.  
  11. </head>
  12. <body onload="boot()">
  13.  
  14. Hello World.      Hello World.      Hello World.      Hello World.  <br />
  15.     Hello World.      Hello World.      Hello World.      Hello World.  <br />
  16.     Hello World.      Hello World.      Hello World.      Hello World.      <br />
  17. Hello World.      Hello World.      Hello World.      Hello World.      Hello World.  <br />
  18.     Hello World.      Hello World.      Hello World.      Hello World.  <br />
  19.     Hello World.      Hello World.      Hello World.      Hello World.      <br />
  20. Hello World.      Hello World.      Hello World.      Hello World.      Hello World.  <br />
  21.     Hello World.      Hello World.      Hello World.      Hello World.      Hello World.  
  22. <script type='text/javascript'>
  23.  
  24.     function boot(){
  25.         document.styleSheets[0].disabled = true;        
  26.         document.title=" Welcome to my page";
  27.     }
  28.  
  29. </script>
  30. </body>
  31. </html>
Sep 29 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.