window.location.href doesn’t redirect

I know this is a question much discussed but I can’t figure out why it does not work for me.

This is my function:

function ShowComments(){

 alert("fired");
 var movieShareId = document.getElementById('movieId');
 //alert("found div" + movieShareId.textContent || movieShareId.innerText);
 //alert("redirect location: /comments.aspx?id=" + movieShareId.textContent || movieShareId.innerText + "/");
 window.location.href = "/comments.aspx?id=" + movieShareId.textContent || movieShareId.innerText + "/";
 var newLocation = window.location;
 //alert("full location: " + window.location);

}

If I have the alerts uncommented or if I have Mozilla’s bugzilla open it works fine, otherwise it does not redirect to the other page.

Any ideas why?

Leave a Comment