如何防止window.location.pathname转义URL中的字符 [英] How to prevent window.location.pathname from escaping characters in URL
问题描述
我正在开发一个Google App Engine应用程序.单击按钮时,我试图将用户重定向到登录页面.为此,我将window.location.pathname
设置为后面的字符串/_ah/login?continue=http%3A//localhost%3A8080/
.但是,chrome对字符串进行了转义,因此完整的URL变为http://localhost:8080/_ah/login%3Fcontinue=http%3A//localhost%3A8080/
,这将产生404错误.如何防止这种情况发生?可用的URL是http://localhost:8080/_ah/login?continue=http%3A//localhost%3A8080/
I am developing a google app engine app. I am trying to redirect user to login page when a button is clicked. To do this I set window.location.pathname
to following string /_ah/login?continue=http%3A//localhost%3A8080/
. However, chrome escapes the string so that the full URL becomes http://localhost:8080/_ah/login%3Fcontinue=http%3A//localhost%3A8080/
, and this gives a 404 error. How can I prevent this from happening? The URL that works is http://localhost:8080/_ah/login?continue=http%3A//localhost%3A8080/
推荐答案
改为设置window.location.href
.
这篇关于如何防止window.location.pathname转义URL中的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!