Test if links are external with jQuery


Source Code:

<script>
	$(document).ready(function(){
		var base_url = location.protocol + "//" + location.host;
		$("a").not(":contains(" + base_url + ")").click(function(){
			this.target = "_blank";
		});
	});
</script>

Reviews and Comments