ios - Startup code in cordova -


i very new in cordova (a few weeks), , building ios app, , trying implement code opens external url in default browser, safari. following tutorial says "use following part of startup code in cordova app":

window.addeventlistener('load', function () { $(document).on('click', 'a[target="_system"],a[target="_blank"]', function (e) {     e.preventdefault();     var url = this.href;     window.open(url,"_system");     }); //} }, false); 

how add part of startup code? script tag @ top of page? tried , got no luck.
here link tutorial using: http://weblog.west-wind.com/posts/2015/jul/02/external-links-in-cordova-for-ios

the code showed should included script tag tried. after need add link element in html , click that. index.html this

<html>   <head>     <script src="cordova.js"></script>     <script type="text/javascript">     window.addeventlistener('load', function () {       $(document).on('click', 'a[target="_system"],a[target="_blank"]', function (e) {         e.preventdefault();         var url = this.href;         window.open(url,"_system");       });     }, false);     </script>   </head>   <body>     <a href="http://google.com/" target="_system">go google.com</a>   </body> </html> 

what script registers event handler click event called every time link target="_system" or target="_blank" clicked. when called, first prevents other event handlers being executed (e.preventdefault();). after reads url link clicked , opens external browser (window.open(url, "_system");).


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -