Home / Admin / Open all external links in new tab
Duplicate Snippet

Embed Snippet on Your Site

Open all external links in new tab

This makes the manual link tab association obsolete. All links to another domain will open in a new tab.

Code Preview
js
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function($) {
$('a').each(function() {
var a = new RegExp('/' + window.location.host + '/');
if(!a.test(this.href)) {
$(this).click(function(event) {
event.preventDefault();
event.stopPropagation();
window.open(this.href, '_blank');
});
}
});
});
//]]>
</script>

Comments

Add a Comment