Is there a way to check whether Javascript is enabled or supported by the browser? If it\'s not supported, I would like to redirect the user to a user-friendly error page. <
As yet another option, you can (though it requires a second page visit) use javascript to set a cookie.
If the cookie exists server-side (they have javascript) render the page as normal. During the absense of the cookie, you can either use a Location
redirect, or render the appropriate [stripped-down] template to accommodate their lack of javascript support.
page html
<script type="text/javascript">
document.cookie = 'hasJS=true';
</script>
page php
if (isset($_COOKIE['hasJS'])){
// normal page render
}else{
header('Location: http://mysite.com/index-nojs.php');
}
Yes. Make you have the latest jQuery.
Javascript:
$(function(){ $('#jsEnabled2').html('Yes it is') })
PHP:
$js - 'No';
$jscheck = 'Javascript Enabled: ';
$jscheck .= '<span id="jsEnabled">'.$js.'</span>';
print $jscheck;
Bring the user to the error page by default, and have a javascript redirect execute in the section of the page. Have the redirect push the user to the real page.
If they don't have javascript enabled, they won't get redirected and the rest of the page (error page) will load.