Jump to content

is JS enabled??


ag3nt42

Recommended Posts

Include a no script tag that has a hidden 1x1 img that is actually a PHP script.

 

In the head section of your template, but only add this part if $_SESSION['JavaScript'] is not yet set.

<noscript>
  <img style="display: none;" src="/noscript.php" alt="Detecting JavaScript" />
</noscript>

 

noscript.php

<?php
  session_start();
  $_SESSION['JavaScript'] = false;
  fpassthru( '/path/to/1x1.gif' );
?>

Link to comment
https://forums.phpfreaks.com/topic/114115-is-js-enabled/#findComment-586560
Share on other sites

<noscript> is an HTML tag where the content is only rendered in a browser when JavaScript is turned off.  The <noscript> tag I gave you has a single item in it, an invisible image.  It just so happens that the src-attribute of the image points at a PHP script you create on the server.  Hence this script is called by the client ONLY if JavaScript is disabled.

 

In the noscript.php on your server, you set a session variable indicating that JavaScript is off.  Then you fpassthru the contents of a 1x1 gif image (because it's supposed to be an image).

Link to comment
https://forums.phpfreaks.com/topic/114115-is-js-enabled/#findComment-586855
Share on other sites

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.