MadCap Flare Tricks: How to Open External Links in a new Window by Default

I’d like to share with you a script I’ve found on the MadCap Forums that you can use to open external links (<a href>) by default in a new target frame.

To do so, you can add the script below to the body part of your page layout (.flmsp):

<script type="text/javascript">/*<![CDATA[*/
$("a[href^='https://']").attr('target="_blank"');/*]]>*/</script>

Note that I’ve slightly modified the original script suggested at https://forums.madcapsoftware.com to fit my needs (http to https and the inverted commas in the attribute).

You can also replace the attribute value (“_blank” in this case) by:

_parent

_self

_top

And apply any other attribute supported by <a>. For a complete list, see: w3schools.com/tags/tag_a.asp

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s