How to detect if I am in browser (local development) in Ionic 2

前端 未结 7 1209
太阳男子
太阳男子 2020-12-03 03:00

I want to make sure to launch inappbrowser only if I am on devices (iOs, Android...), but if I am in browser (local development mode or just a Web App with gulp build), I wa

7条回答
  •  执笔经年
    2020-12-03 03:17

    Here you go., you can use the following function in replacement of your click function.

    onClickOfButton(){
          // Check If Cordova/Mobile
       if (this.platform.is('cordova')) {
            window.location.href = url;
       }else{
            window.open(url,'_blank');
       }
    }
    

    This can be helpful :)

提交回复
热议问题