admin管理员组文章数量:1221309
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/
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/
3 Answers
Reset to default 12Set window.location.href
instead.
I think you're better off just using window.location.href. In both Chrome and Firefox window.location.href="/?foofoo"
redirects to <domain:port>/?foofoo
You can use the following code in javascript to decode URI components:
decodeURIComponent(window.location.pathname)
本文标签: javascriptHow to prevent windowlocationpathname from escaping characters in URLStack Overflow
版权声明:本文标题:javascript - How to prevent window.location.pathname from escaping characters in URL - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739269695a2155763.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
replace('%3F','?')
at the end... I my case the suggested 'use location directly' is not applicable since I am manipulating href attribute of buttons that will fetch ajax content. – nicolallias Commented Sep 19, 2018 at 17:00