Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phone gap 3.0 + sencha touch open urls in device browser

Am building an android app using sencha touch + phonegap 3.0, requirement to open some urls in external browser. For Ios am using Ext.device.Device.openURL(url), and its working fine. But in android when i click on link, its open in my appview..

What i tried is

window.open(url, '_system', 'location=no'); // not worked still opens the in app view

window.open(alltaskurl,  '_blank', 'location=yes'); // not worked opens in app view 

Then i installed InAppBrowser phoneGap plugin and tried changed my config.xml file

   <feature name="InAppBrowser">
        <param name="android-package" value="org.apache.cordova.InAppBrowser" />
    </feature>

window.open('http://apache.org', '_blank', 'location=yes'); // not worked as well 

I dont know what to do with this, am spending a lot of time to solve this issue, please help me..thanks in advance

like image 320
Dibish Avatar asked Nov 20 '25 05:11

Dibish


2 Answers

Once you installed InAppBrowser use:

window.open(url, '_system');
like image 177
benka Avatar answered Nov 21 '25 17:11

benka


thanks Dibish.. you put me on the right track. I'm using a library that does some of it's own href's so, to avoid messing with that library I did this instead:

window.onclick = clickEvent;

function clickEvent(e){
    e = e || window.event;
    var t = e.target || e.srcElement
    if ( t.name || t.href ){
       if( typeof t.href == "string" && t.href.substr(0,4) == 'http' ){
           if( t.attributes.href.value !== "#" ){
               window.open(t.href, '_system', 'location=yes');
           }
           return false; // no further action for this click
       }
    }
    return true; // process click as normal
}

edit: used window.open() instead of Android specific navigator.app.loadUrl() . I also had to weed out href="#" occurrences.

like image 39
JJones Avatar answered Nov 21 '25 18:11

JJones



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!