Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent window.location.pathname from escaping characters in URL

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/

like image 654
morpheus Avatar asked Jun 28 '11 02:06

morpheus


People also ask

What does Window location pathname do?

window.location.pathname returns the path and filename of the current page. window.location.protocol returns the web protocol used (http: or https:) window.location.assign() loads a new document.

How does window location href work?

window. location. href is not a method, it's a property that will tell you the current URL location of the browser. Changing the value of the property will redirect the page.

What is location pathname?

pathname. The pathname property of the Location interface is a string containing the path of the URL for the location, which will be the empty string if there is no path.


1 Answers

Set window.location.href instead.

like image 167
Ry- Avatar answered Sep 28 '22 08:09

Ry-