views:

71

answers:

3

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...

+2  A: 
window.location.href = "../index.html";

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

Tim Down
Do I need relative or absolute paths? Shouldn't matter right... hmmBTW: This is in a separate js file which is included... Maybe thats the reason?
Camran
Doesn't matter about the separate .js file: the URL is calculated relative to the page, not the .js file. Relative paths are absolutely fine too.
Tim Down
A: 

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

Matachana
A: 

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"

Jeff Davis