[removed].href doesn't redirect

后端 未结 10 1972
Happy的楠姐
Happy的楠姐 2020-12-18 17:40

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(\         


        
10条回答
  •  温柔的废话
    2020-12-18 18:31

    window.location.replace is the best way to emulate a redirect:

    function ShowComments(){
        var movieShareId = document.getElementById('movieId');
        window.location.replace("/comments.aspx?id=" + (movieShareId.textContent || movieShareId.innerText) + "/");
    }
    

    More information about why window.location.replace is the best javascript redirect can be found right here.

提交回复
热议问题