Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why won't window.location load a new page?

This bit of code used to work, and now it doesn't:

var url = myurl +'?id=' + id + '&phase=' + phase;
window.location = url;

Using the IE dev toolbar I've verified that url has a valid url, and window.location returns the new url...the only problem is the page does not reload.

Does anyone know of any reasons for window.location to now actually load a new document when it is assigned to?

like image 979
IronicMuffin Avatar asked Jul 20 '11 15:07

IronicMuffin


2 Answers

Use window.location.href = url; instead.

like image 166
Nick Avatar answered Oct 12 '22 03:10

Nick


Is your JavaScript running the onclick event from an <input> type="button" or type="submit"?

If your button is type="submit" it won't work unless you stop the submission from executing.

I know this is kind of obvious but I didn't see this in the other comments so I might just add to this thread.

like image 21
Manolo Avatar answered Oct 12 '22 03:10

Manolo