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)
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