Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.location Does Not Work on Chrome Browser [closed]

I have a javascript function that uses window.location. It works fine in Firefox and internet Explorer, but not in Chrome. I've tested this on both Ubunutu Hardy and Windows Vista. What is the underlying problem, and how can I circumvent it?

like image 650
Bad Programmer Avatar asked Feb 27 '10 00:02

Bad Programmer


People also ask

What can I use instead of a window location?

You can use location.location. assign.

How do I get Chrome debug logs?

Collect network logsOn the affected device, enter chrome://network in the address bar. At the top, click Network logs. Under Network debugging, select the correct debug mode. Open a new tab and reproduce the issue.

What does Window location assign do?

The Location. assign() method causes the window to load and display the document at the URL specified. After the navigation occurs, the user can navigate back to the page that called Location.

What is window location href?

Window Location Href The window.location.href property returns the URL of the current page.


2 Answers

The most common use of window.location is to make the browser load a new page. A common error is to assign the URL to the window.location object instead of it's property href. So, the correct way to do it is:

window.location.href = 'http://www.guffa.com';
like image 87
Guffa Avatar answered Sep 17 '22 18:09

Guffa


Try appending "return false;" to your javascript call like so...

window.location.href='google.com;
return false;
like image 23
Baxtrum Avatar answered Sep 19 '22 18:09

Baxtrum