2014-07-02 68 views
0

I have a very big web page with many sub pages. Inside html code there is a lot of 's that leads to external pages. I have to transform this pages into phonegap app. Every link has to be open in system browser. I know that in phonegap I should use onclick="window.open(...) but is there any easier way in order not to have modify every singe in my old code(there is hundreds of them)?Phonegap - <a href> open in system browser

+0

這只是一個想法,並沒有優化。您可以在點擊鏈接之前定義事件。這個事件會做window.open()並通過返回false來避免鏈接。 – jedema

+0

[InAppBrowser](http://docs.phonegap.com/en/3.3.0/cordova_inappbrowser_inappbrowser.md.html)插件在這種情況下可能會有幫助。 – byJeevan

回答

0

If every instance of the <a> can be overridden, and assuming you have jQuery, try binding all clicks on the <a> tags.

$('a').click(function(event) { 
    event.preventDefault(); 
    window.open($(this).attr('href')); 
}); 
0

you can use InAppBrowser plugin

cordova plugin add org.apache.cordova.inappbrowser

then you can use

window.open('http://apache.org','_system');

在系統瀏覽器中打開!

相關問題