I recently needed a Javascript check for use on a site, and I was awefully surprised when I saw the tutorials, or lack of. You’d think something that simple would be shown all over the place, but it’s not, so I spent 5 minutes of MY OWN TIME to write one, and I figured I would put it out in case someone needs a quick and dirty one.
/**********************************************************************/
/* GHETTO JAVASCRIPT CHECK */
/**********************************************************************/
if ((!$_SESSION['_JAVASCRIPT_']) && !isset($_POST['javascripttest'])) {
echo "<HTML><HEAD><TITLE>Ghetto Javascript Check</TITLE></HESD>
";
echo "<BODY ONLOAD=\"document.GhettoTest.submit()\">
";
echo "<NOSCRIPT>You must have Javascript enabled to use this website.</NOSCRIPT>
";
echo "<FORM NAME=\"GhettoTest\" METHOD=\"POST\" ACTION=\"". $_SERVER["REQUEST_URI"] ."\">
";
echo "<INPUT TYPE=\"hidden\" NAME=\"javascripttest\" VALUE=\"Javascript Works!\">
";
echo "</FORM></BODY></HTML>";
}
if (isset($_POST['javascripttest'])) {
$_SESSION['_JAVASCRIPT_'] = true;
}