I know this is a question much discussed but I cant 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?
window.location.replace
is the best way to emulate a redirect:More information about why
window.location.replace
is the best javascript redirect can be found right here.