<a href="https://blog.csdn.net/?spm=1001.2101.3001.4477" target="_blank">This link will open in new window/tab</a>
内联JavaScript方式:
<a href="https://blog.csdn.net/?spm=1001.2101.3001.4477" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">This link will open in new window/tab</a>
使用jQuery:
$('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');
});
}
});
HTNL属性:<a href="https://blog.csdn.net/?spm=1001.2101.3001.4477" target="_blank">This link will open in new window/tab</a>内联JavaScript方式:<a href="https://blog.csdn.net/?spm=1001.2101.3001.4477" onclick="window.open(this.href); return