1

The command:

document.location.href="www.google.com" 

Does not change the current web page in the google chrome browser. The command does transfer the page in the IE9 browser.

Why would this command work for IE9 but not for chrome?

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Ashwin G
  • 1,570
  • 1
  • 16
  • 23

2 Answers2

8

You need to add the protocol:

document.location.href="http://www.google.com";
Mendhak
  • 8,194
  • 5
  • 47
  • 64
  • Add a slight delay before the actual redirect.You can use setTimeout for that. I had the same problem, added protocol and wrapped setting the href into a setTimeout and now it works. – Zahir J Jan 30 '18 at 08:59
7

An alternative solution is to add this line before document.location.href

window.event.returnValue = false;

Source: document.location does not change the webpage in IE9?

Community
  • 1
  • 1
Ashwin G
  • 1,570
  • 1
  • 16
  • 23