简体   繁体   中英

Cordova 3.5 - Android open links in the mobile system browser not working at all

I'm aware that this has been asked plenty of times. But for the life of me I can't seem to get it to work with all those solutions.

I'm using cordova 3.5 + jquery mobile(for designing) + some js plugins.

These are the things i've tried and done rnd with:

navigator.app.loadUrl("http://google.com", {openExternal : true});

<a onclick="navigator.app.loadUrl('https://google.com/', { openExternal:true });">Link</a>

Here I get the error navigator not found and the links just keep opening inside the app.

Then I follower some ideas from here :

<access origin="http://alunny.github.com" browserOnly="true" />

In this the browserOnly gets changed when I build it using cordova and then obviously the change doesn't happend.

One more way I then found using a JS function is:

<script type="text/javascript">
           $('a[target=_blank]').on('click', function(e) {
           e.preventDefault();
           window.open($(this).attr('href'), '_system');
           return false;
       }); 
    </script>

Here too nothing happens.

I should mention most of these are last year's answers and none mention Cordova 3.5.0-0.2.6 .

Hence I start this thread for this specific version, I'd really appreciate some help. The phone I'm testing on is Moto G running Android 4.4.4.

The answer accepted in the link provided by sagar is the solution.I tried in motog running android 4.4 and it is working fine.Added this window.open( ' http://www.google.de ', '_system'); and installed the inapp browser plugin in the project directory.

My cordova version is 3.4 but i think that shouldnt make a difference

Link I followed http://community.phonegap.com/nitobi/topics/open_external_links_in_system_browser_phonegap_build_3_1_iphone_android_windows

Have posted a sample test project i created based on the example u needed https://gist.github.com/rahulinaction/f5d347ea9c74a941273e

Here is a simple demo:

<h1 onclick="window.open('yourWebsiteAddress')">HELLO THERE EVERYONE</h1>

Also you need to add the cordova plugin: org.apache.cordova.inappbrowser

Use this link .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM