Block if javascript is disabled

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chathura86
    New Member
    • May 2007
    • 227

    Block if javascript is disabled

    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
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Instead of trying to block the user, use the <noscript> tag to display content or a message when JavaScript is disabled.

    Comment

    • chathura86
      New Member
      • May 2007
      • 227

      #3
      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

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        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?

        Comment

        • rnd me
          Recognized Expert Contributor
          • Jun 2007
          • 427

          #5
          Code:
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <head>
          <title>JavaScript Required!</title>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
          
          <style type='text/css'>
          	body { display	: none; }
          </style>
          
          </head>
          <body onload="boot()">
          
          Hello World.  	Hello World.  	Hello World.  	Hello World.  <br />
          	Hello World.  	Hello World.  	Hello World.  	Hello World.  <br />
          	Hello World.  	Hello World.  	Hello World.  	Hello World.  	<br />
          Hello World.  	Hello World.  	Hello World.  	Hello World.  	Hello World.  <br />
          	Hello World.  	Hello World.  	Hello World.  	Hello World.  <br />
          	Hello World.  	Hello World.  	Hello World.  	Hello World.  	<br />
          Hello World.  	Hello World.  	Hello World.  	Hello World.  	Hello World.  <br />
          	Hello World.  	Hello World.  	Hello World.  	Hello World.  	Hello World.  
          <script type='text/javascript'>
          
          	function boot(){
          		document.styleSheets[0].disabled = true;		
          		document.title=" Welcome to my page";
          	}
          
          </script>
          </body>
          </html>

          Comment

          Working...