user188962
user188962

Reputation:

redirect wont work in Chrome

I have a form on my website. When this form is filled out, it is then validated by a javascript validation function.

At the bottom of this function I have this piece of code:

  window.location="../index.html";

This wont work on Chrome, but does work in Firefox.

My Q is, how can I make this simple redirect work on all (most) browsers?

Thanks

EDIT:

This is in a separate js file which is included...

Upvotes: 0

Views: 668

Answers (3)

Jeff Davis
Jeff Davis

Reputation: 4797

The ../ is not really a valid URL.

If you want to go to your html root (where your index.html is most likely located), simply use "/index.html"

Upvotes: 0

Matachana
Matachana

Reputation: 303

window.location works for me in Google Chrome as well as in Firefox.

Upvotes: 0

Tim Down
Tim Down

Reputation: 324507

window.location.href = "../index.html";

... is the preferred way, although setting window.location does work in Chrome.

Upvotes: 1

Related Questions