phonegap - open link in browser

后端 未结 9 814
一向
一向 2020-12-08 22:52

I use phonegap (cordova 2.2)

I have link like this :

twitter
相关标签:
9条回答
  • 2020-12-08 23:15

    I use this as a general rule:

    $('a').live('tap',function(e){
        // if external link then open a browser
        if(String($(this).attr('href')).substring(0,4)=='http' || String($(this).attr('href')).substring(0,5)=='https'){
            navigator.app.loadUrl($(this).attr('href'), { openExternal:true });
            e.stopPropagation();
            return false;
        }
    });
    
    0 讨论(0)
  • 2020-12-08 23:17

    Navigator for phonegap works!

    handler: function (btn, evt) {
    loadURL('http://www.google.com');
    }
    

    ...

    function loadURL(url){
    navigator.app.loadUrl(url, { openExternal:true });
    return false;
    } 
    
    0 讨论(0)
  • 2020-12-08 23:19

    Try this for android:

    function loadURL(url){
        navigator.app.loadUrl(url, { openExternal:true });
        return false;
    } 
    

    Html:

    <a click="loadURL('http://twitter.com/foobar')">twitter</a>
    

    You can also try this in your config.xml:

    <access origin="*twitter.com" browserOnly="true"/> 
    
    0 讨论(0)
提交回复
热议问题