Redirect if no JavaScript [duplicate]

夙愿已清 提交于 2019-12-12 06:09:23

问题


Here's my situation:

I'm trying to redirect users with JavaScript disabled to a PHP generated page (instead of an AJAX generated page) on my Apache server.

I'm currently using:

<noscript> <meta http-equiv="refresh" content="0; url=http://mydomain/no_js.php"> </noscript>

Is there a way to redirect users BEFORE the page loads?

P.S.: If not then any way faster than the one I'm currently using?

Thanks in advance!


回答1:


If you need to redirect, make the PHP version the default and redirect if javascript is enabled. I would avoid this though and not have a redirect at all and just display on the same page based on whether javascript is enabled/disabled. You can show the javascript items if enabled. I usually have a class name no-script in the body of the page and remove it if javascript is enabled, you can then use CSS to target what to display based on that one tag.




回答2:


Not sure if this is going to do what youre looking for but here goes:

  1. First, create a page that checks to see wether or not javascript is active
  2. Second, if javascript is active, redirect to the correct page
  3. If not, redirect to the page created for when its not active

that way the page that you have without js enabled never lads without js bwing enabled. not in the slightest. If you REALLY need scripts just holler...



来源:https://stackoverflow.com/questions/14988290/redirect-if-no-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!