解决方法
Gdoron已经提到了noscript.与
meta refresh¹一起,如果禁用JavaScript,您可以重定向用户.
可以使用location.replace(URL)
完成JavaScript重定向.
<head> <noscript> <Meta http-equiv="refresh" content="0; url=http://example.com/without-js" /> </noscript> <script> location.replace('http://example.com/with-js'); </script> </head>
noscript元刷新示例:http://pastehtml.com/view/bsrxxl7cw.html
Meta refresh tags have some drawbacks:
- If a page redirects too quickly (less than 2-3 seconds),using the “Back” button on the next page may cause some browsers to move back to the redirecting page,whereupon the redirect will occur again. This is bad for usability,as this may cause a reader to be “stuck” on the last website.
- A reader may or may not want to be redirected to a different page,which can lead to user dissatisfaction or raise concerns about security.