Skip to main content
Added check for $_SERVER['HTTP_X_REQUESTED_WITH'], if it is set then obviously jQuery is enabled
Source Link
Andy Braham
  • 10.3k
  • 4
  • 57
  • 61

Here is a small include I made up that I have on top of my pages to detect if js is enabled. Hope this helps out...

<?php //Check if we should check for js if ((!isset($_GET['jsEnabled']) || $_GET['jsEnabled'] == 'true') && !isset($_SERVER['HTTP_X_REQUESTED_WITH'])){ //Check to see if we already found js enabled if (!isset($_SESSION['javaEnabled'])){ //Check if we were redirected by javascript if (isset($_GET['jsEnabled'])){ //Check if we have started a session if(session_id() == '') { session_start(); } //Set session variable that we have js enabled $_SESSION['javaEnabled'] = true; } else{ $reqUrl = $_SERVER['REQUEST_URI']; $paramConnector = (strpos($reqUrl, "?"))? "&" : "?"; echo " <script type='text/javascript'> window.location = '" . $reqUrl . $paramConnector . "jsEnabled=true' </script> <noscript> <!-- Redirect to page and tell us that JS is not enabled --> <meta HTTP-EQUIV='REFRESH' content='0; " . $reqUrl . $paramConnector . "jsEnabled=false'> </noscript> "; //Break out and try again to check js exit; } } } ?> 

Here is a small include I made up that I have on top of my pages to detect if js is enabled. Hope this helps out...

<?php //Check if we should check for js if (!isset($_GET['jsEnabled']) || $_GET['jsEnabled'] == 'true'){ //Check to see if we already found js enabled if (!isset($_SESSION['javaEnabled'])){ //Check if we were redirected by javascript if (isset($_GET['jsEnabled'])){ //Check if we have started a session if(session_id() == '') { session_start(); } //Set session variable that we have js enabled $_SESSION['javaEnabled'] = true; } else{ $reqUrl = $_SERVER['REQUEST_URI']; $paramConnector = (strpos($reqUrl, "?"))? "&" : "?"; echo " <script type='text/javascript'> window.location = '" . $reqUrl . $paramConnector . "jsEnabled=true' </script> <noscript> <!-- Redirect to page and tell us that JS is not enabled --> <meta HTTP-EQUIV='REFRESH' content='0; " . $reqUrl . $paramConnector . "jsEnabled=false'> </noscript> "; //Break out and try again to check js exit; } } } ?> 

Here is a small include I made up that I have on top of my pages to detect if js is enabled. Hope this helps out...

<?php //Check if we should check for js if ((!isset($_GET['jsEnabled']) || $_GET['jsEnabled'] == 'true') && !isset($_SERVER['HTTP_X_REQUESTED_WITH'])){ //Check to see if we already found js enabled if (!isset($_SESSION['javaEnabled'])){ //Check if we were redirected by javascript if (isset($_GET['jsEnabled'])){ //Check if we have started a session if(session_id() == '') { session_start(); } //Set session variable that we have js enabled $_SESSION['javaEnabled'] = true; } else{ $reqUrl = $_SERVER['REQUEST_URI']; $paramConnector = (strpos($reqUrl, "?"))? "&" : "?"; echo " <script type='text/javascript'> window.location = '" . $reqUrl . $paramConnector . "jsEnabled=true' </script> <noscript> <!-- Redirect to page and tell us that JS is not enabled --> <meta HTTP-EQUIV='REFRESH' content='0; " . $reqUrl . $paramConnector . "jsEnabled=false'> </noscript> "; //Break out and try again to check js exit; } } } ?> 
added 293 characters in body
Source Link
Andy Braham
  • 10.3k
  • 4
  • 57
  • 61

Here is a small include I made up that I have on top of my pages to detect if js is enabled. Hope this helps out...

<?php //Check if we should check for js if (!isset($_GET['jsEnabled']) || $_GET['jsEnabled'] == 'true'){ //Check to see if we already found js enabled  if (!isset($_SESSION['javaEnabled'])){   //Check if we were redirected by javascript   if (isset($_GET['jsEnabled'])){   //Check if we have started a session   if(session_id() == '') {   session_start();   }   //Set session variable that we have js enabled   $_SESSION['javaEnabled'] = true;   }   else{   $reqUrl = $_SERVER['REQUEST_URI'];   $paramConnector = (strpos($reqUrl, "?"))? "&" : "?";   echo "   <script type='text/javascript'>   window.location = '" . $reqUrl . $paramConnector . "jsEnabled=true'   </script>   <noscript> We're sorry but javascript<!-- mustRedirect beto page and tell us that JS is not enabled to-->  view this website <meta HTTP-EQUIV='REFRESH' content='0; " . $reqUrl . $paramConnector . "jsEnabled=false'>   </noscript>   ";   //Break out and try again if weto havecheck js enabled   exit; } } } ?> 

Here is a small include I made up that I have on top of my pages to detect if js is enabled. Hope this helps out...

<?php //Check to see if we already found js enabled if (!isset($_SESSION['javaEnabled'])){ //Check if we were redirected by javascript if (isset($_GET['jsEnabled'])){ //Check if we have started a session if(session_id() == '') { session_start(); } //Set session variable that we have js enabled $_SESSION['javaEnabled'] = true; } else{ $reqUrl = $_SERVER['REQUEST_URI']; $paramConnector = (strpos($reqUrl, "?"))? "&" : "?"; echo " <script type='text/javascript'> window.location = '" . $reqUrl . $paramConnector . "jsEnabled=true' </script> <noscript> We're sorry but javascript must be enabled to view this website </noscript> "; //Break out and try again if we have js enabled exit; } } ?> 

Here is a small include I made up that I have on top of my pages to detect if js is enabled. Hope this helps out...

<?php //Check if we should check for js if (!isset($_GET['jsEnabled']) || $_GET['jsEnabled'] == 'true'){ //Check to see if we already found js enabled  if (!isset($_SESSION['javaEnabled'])){   //Check if we were redirected by javascript   if (isset($_GET['jsEnabled'])){   //Check if we have started a session   if(session_id() == '') {   session_start();   }   //Set session variable that we have js enabled   $_SESSION['javaEnabled'] = true;   }   else{   $reqUrl = $_SERVER['REQUEST_URI'];   $paramConnector = (strpos($reqUrl, "?"))? "&" : "?";   echo "   <script type='text/javascript'>   window.location = '" . $reqUrl . $paramConnector . "jsEnabled=true'   </script>   <noscript> <!-- Redirect to page and tell us that JS is not enabled -->   <meta HTTP-EQUIV='REFRESH' content='0; " . $reqUrl . $paramConnector . "jsEnabled=false'>   </noscript>   ";   //Break out and try again to check js   exit; } } } ?> 
Source Link
Andy Braham
  • 10.3k
  • 4
  • 57
  • 61

Here is a small include I made up that I have on top of my pages to detect if js is enabled. Hope this helps out...

<?php //Check to see if we already found js enabled if (!isset($_SESSION['javaEnabled'])){ //Check if we were redirected by javascript if (isset($_GET['jsEnabled'])){ //Check if we have started a session if(session_id() == '') { session_start(); } //Set session variable that we have js enabled $_SESSION['javaEnabled'] = true; } else{ $reqUrl = $_SERVER['REQUEST_URI']; $paramConnector = (strpos($reqUrl, "?"))? "&" : "?"; echo " <script type='text/javascript'> window.location = '" . $reqUrl . $paramConnector . "jsEnabled=true' </script> <noscript> We're sorry but javascript must be enabled to view this website </noscript> "; //Break out and try again if we have js enabled exit; } } ?>