
Untitled
By: a guest on
Aug 10th, 2012 | syntax:
None | size: 0.55 KB | hits: 6 | expires: Never
How to automatically open external links in new tab with PHP redirects?
<a href="http://www.website-shown-browser.com" onclick="this.href='http://'+window.location.host+'/visit/redirect.php'">Website</a>
$('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');
});
}
});
$("#content a[href^='http://']").attr("target","_blank");