phili
phili

Reputation: 385

Why does this not cause a browser redirect?

if (selectedddItem.toString().indexOf("6ft with two") > -1) {
  window.location = "http://www.google.com/";
  alert("just passed over");
}

The alert window opens so the condition is true... however the browser doesn't redirect?!?!

Any thoughts?

Upvotes: 1

Views: 153

Answers (3)

anubhava
anubhava

Reputation: 786329

Have your code like this:

if (selectedddItem.toString().indexOf("6ft with two") > -1) {
  alert("just passed over");
  top.location.href = "http://www.google.com/";
}

Make sure you are seeing this alert first before browser redirect otherwise your if condition is returning false.

Upvotes: 0

jAndy
jAndy

Reputation: 236202

Depending on the browser you are using, window.location = might be not enough.

Try to "full qualify" with window.location.href = "http://www.google.com";

However, there is zero jQueryfication in that code :-)

Upvotes: 3

Chris Cherry
Chris Cherry

Reputation: 28574

window.location.href

Is what you are looking for

Upvotes: 0

Related Questions