gregjacobs / Autolinker.js

Utility to Automatically Link URLs, Email Addresses, Phone Numbers, Twitter handles, and Hashtags in a given block of text/HTML
MIT License
1.48k stars 238 forks source link

Allowing option to specify target for cordova compatibility #141

Open davistan opened 8 years ago

davistan commented 8 years ago

Thanks for this plugin and I've found that to allow it to work in cordova / phonegap, we need to use target="_system" instead of _blank.

This is required in Cordova's InAppBrowser plugin. Perhaps can include an option to specify the target instead of just newWindow?

Thanks.

BadSector82 commented 8 years ago

+1 please!

gregjacobs commented 8 years ago

Hey, interesting. Will see what I can come up with.

Here's a workaround for the meantime:

var html = Autolinker.link( "Test google.com", {
    replaceFn : function( autolinker, match ) {
        var tag = match.buildTag();  // returns an Autolinker.HtmlTag instance
        tag.setAttr( 'target', '_system' );

        return tag;
    }
} );
c-jacquin commented 8 years ago

+1 thx for the workaround