views:

111

answers:

3

Hi All,

I have a asp.net webform with a button. The OnClientClick event is wired to a javascript function.

I need this function to redirect the current page to this page.

After much reading is have tried all the following, but to no avail:

           var url = "http://www.google.com";
           document.location = url; //Doesn't Work
           document.location.href = url; //Doesn't Work
           window.location = url; //Doesnt Work
           window.location.href = url; //Doesnt Work

Any Help or advice are welcome.

Ps. I am entering the JS function as my alert message pops up

+1  A: 

I tried this in a html page and it worked fine.

function go() { alert(); var url = "http://www.google.com"; document.location.href = url; //Doesn't Work }

Just look at the page source and see whether onClientClick is calling your js function

Krishna Kumar
A: 

you could try location.replace(myUrl); but docmunet.location.href should really work

Vladimir Kocjancic
A: 

You probably have somewhere on your code a Javascript Error, that stop the execution, because as the other say, this code that you say that "doesnt work", it's work fine.

Aristos
Hi Looks like I had a JS error causing a gremlin. Thanks
SetiSeeker