PHP ver gevorderde |
|
<?
session_start();
if(jsEnabled() === false)
{
echo 'Zet JS aan!';
}
function jsEnabled()
{
// did we already checked this??
// yes
if(isset($_SESSION['JS_enabled']))
{
return $_SESSION['JS_enabled'];
}
// nope
else
{
// if we set the var
if(isset($_GET['jsEnabled']))
{
$_SESSION['JS_enabled'] = ($_GET['jsEnabled'] == 1);
}
//
else
{
// if JS = enabled, redict to ?jsEnabled=1
echo "<script>location.href='?jsEnabled=1'</script>";
// if not, this wil be the link...
echo '<meta http-equiv="refresh" content="0; URL=?jsEnabled=0">';
// exit, nothing else is inportant!
exit;
}
}
}
?>
<? if(jsEnabled() === false) { } function jsEnabled() { // did we already checked this?? // yes if(isset($_SESSION['JS_enabled'])) { return $_SESSION['JS_enabled']; } // nope else { // if we set the var if(isset($_GET['jsEnabled'])) { $_SESSION['JS_enabled'] = ($_GET['jsEnabled'] == 1); } // else { // if JS = enabled, redict to ?jsEnabled=1 echo "<script>location.href='?jsEnabled=1'</script>"; // if not, this wil be the link... echo '<meta http-equiv="refresh" content="0; URL=?jsEnabled=0">'; // exit, nothing else is inportant! } } } ?>
Dat is de manier die me als eerste te binnen schoot (en het werkt ook nog) |