Skip to content

Instantly share code, notes, and snippets.

@shazron
Last active September 17, 2020 17:58
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shazron/4694032 to your computer and use it in GitHub Desktop.
Save shazron/4694032 to your computer and use it in GitHub Desktop.
Anchor tag link replace for InAppBrowser (Apache Cordova)
// warning, jQuery code below
$(document).ready(function() {
var $a = $("a");
$a.click(function(x) {
x.preventDefault();
var url = $(this).attr('href');
launchUrl(url); // where launchUrl is your function that calls window.open, etc
});
});
@JonathanHindi
Copy link

I do something like this to handle external links only https://gist.github.com/JonathanHindi/6301111

@georgir
Copy link

georgir commented Aug 21, 2014

but this is not enough for dynamic content, content inside iframes, etc

@Andrewglass1
Copy link

@geogir I'm experiencing the same issue. were you able to find a work-around?

@kennypetrowski
Copy link

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!

@poornerd
Copy link

ditto -> I have the same problem. I want to open dynamically generated links in an iframe (with code I do not control) in the inAppBrowser.

@benmcmaster
Copy link

Yep I have this problem too... the little youtube logo in embedded youtube videos open in the current webview in my app. You have to quit the app to get back. Terrible experience.

@ladmerc
Copy link

ladmerc commented Sep 30, 2016

Hey @benmcmaster, any luck resolving this?

@mahesha-mahi
Copy link

Is it possible to make anchor tags in iframe also opens in inappbrowser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment