[removed].href doesn't redirect

后端 未结 10 1971
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:36

    If you are calling this function through a submit button. This may be the reason why the browser does not redirect. It will run the code in the function and then submit the page instead of redirect. In this case change the type tag of your button.

    0 讨论(0)
  • 2020-12-18 18:39

    Make sure you're not sending a '#' at the end of your URL. In my case, that was preventing window.location.href from working.

    0 讨论(0)
  • 2020-12-18 18:40

    In my case it is working as expected for all browsers after setting time interval.

    setTimeout(function(){document.location.href = "myNextPage.html;"},100);
    
    0 讨论(0)
  • 2020-12-18 18:42

    window.location.href wasn't working in Android. I cleared cache in Android Chrome and it works fine. Suggest trying this first before getting involved in various coding.

    0 讨论(0)
提交回复
热议问题