Android redirect does not work

后端 未结 5 1284
故里飘歌
故里飘歌 2021-01-02 08:03

I need to redirect in a javascript file to a given URI specified by the user.

So a quick example how I do this:

function redirect(uri) {
  if(navigat         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-02 08:56

    Android supports document.location without the href property

    Try to use:

    function redirect(uri) {
      if(navigator.userAgent.match(/Android/i)) 
        document.location=uri;      
      else
        window.location.replace(uri);
    }
    

提交回复
热议问题