/* Handle any link start with http or https using PhoneGap (Cordova) inAppBrowser | |
* Options you can set data-in-app-browser html attribute to one of the | |
* following options: | |
* _self - opens in the Cordova WebView if url is in the white-list, else it opens in the InAppBrowser | |
* _blank - always open in the InAppBrowser | |
* _system - always open in the system web browse | |
*/ | |
$(document).on('click', 'a[href^=http], a[href^=https]', function(e){ | |
e.preventDefault(); | |
var $this = $(this); | |
var target = $this.data('inAppBrowser') || '_blank'; | |
window.open($this.attr('href'), target, 'location=no'); | |
}); |
This comment has been minimized.
This comment has been minimized.
@mtamony You are welcome.. |
This comment has been minimized.
This comment has been minimized.
mtamony
commented
Feb 25, 2014
Jonathan do you have any idea how I can eliminate certain links from this code? I've run into a problem with all links opening with InApp. Google maps used to open on Android with maps:q= but now it doesn't. This worked great because it avoided InApp and opened the Google maps app. Now I'm adding http://maps.google.com to get it to work and InApp is grabbing the link. Google maps in the InApp browser is terrible. |
This comment has been minimized.
This comment has been minimized.
ghost
commented
Jul 12, 2014
How would this work if i need to POST a form to an external URL and want to open it in the InApp Browser ? |
This comment has been minimized.
This comment has been minimized.
DmitryAnzin
commented
Aug 25, 2014
Thank you very much!! You really help me! |
This comment has been minimized.
This comment has been minimized.
freddiescott
commented
Jan 8, 2015
Thanks ! |
This comment has been minimized.
This comment has been minimized.
kennypetrowski
commented
Jun 19, 2015
Dumb question, but... how exactly do I call this into my Ionic project? I get that I should create the js file, reference it in index.html, but any other code I need to add to the above to make it update all my links to open in the inAppBrowser? Thanks! |
This comment has been minimized.
This comment has been minimized.
JPustkuchen
commented
Dec 9, 2019
Hi I ran into a similar problem because download links (e.g. .pdf) don't work in inAppBrowser, I finally found a working solution with inAppBrowser 3.1.0 using beforeload event: https://julian.pustkuchen.com/node/809 Perhaps my solution helps you or others. I also lost several hours on this. |
This comment has been minimized.
mtamony commentedSep 6, 2013
Yes!!!! Thank you so much this is a lifesaver!