Check whether Javascript is enabled

2019-02-03 18:23发布

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.

I am using jQuery and the PHP Zend Framework.

9条回答
唯我独甜
2楼-- · 2019-02-03 18:56

As the default, send out the version without javascript. There you include a little piece of javascript that redirects to the dynamic version. This will only get executed when js is enabled.

查看更多
等我变得足够好
3楼-- · 2019-02-03 18:56

You can make a simple "landing page" for users without javascript AND add a javascript redirection to the javascript-enabled version of site.

Something like this:

...
<html>
...
<script type="text/javascript">
 window.location.replace("/hasjs");
</script>
查看更多
淡お忘
4楼-- · 2019-02-03 18:59

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.

查看更多
登录 后发表回答