Open ad links in an external browser

2 posts, 0 answers
  1. Nathaniel
    Nathaniel avatar
    7 posts
    Member since:
    Feb 2015

    Posted 25 Sep 2015 Link to this post

    In my app I use JWPlayer to show videos and ads. If a user clicks on an ad in a video, my entire webview (and app) redirects to the ad URL which makes my app useless until it's restarted.

    When I want to manually direct a user to a webpage, I currently use:

    function nav() {
        if ( {
  "", { openExternal:true } );
        } else if ( {
  "", '_system');
        } else {
            alert("something went wrong");

    But I have no control  over the links in the player.

    Is there a way to adapt the code above or is there different method that would allow me to open all ad links in an external browser?


  2. Martin Yankov
    Martin Yankov avatar
    177 posts

    Posted 30 Sep 2015 Link to this post

    Hello Nathaniel,

    Thank you for contacting us.

    Currently, Cordova doesn't provide a mechanism to intercept all outgoing links and modify them. You will have to come with a custom solution to fix this problem. I took a look at this player and it seems it's a HTML5 player, which is good. Furthermore, it's loaded in an iframe. So my first idea would be to try to find the links in the player and their classes. You can also try to check all clicked/tapped links like this:
    $('iframe').on('click', 'a', function(e) {
        // get the href attribute value and use
        // prevent the default behavior.

    This is only an idea. If you open a support ticket and send us a sample project I could try this out and investigate it further.

    I hope this helps.

    Martin Yankov

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

Back to Top