Reputation: 119
I am using below code to covert all links pass through a php script - Now i want these links to pop open in a new window
$( document ).ready(function() {
$("a[href^='http']").each(function() {
var value = $(this).attr('href');
$(this).attr('href','<url>/pqr.php?'+value);
});
});
Links are opening in same window? How to get them opened in a new window.
Upvotes: 0
Views: 608
Reputation: 8224
What about adding this:
$(this).attr("target","_blank");
EDIT: integrated like this:
$( document ).ready(function() {
$("a[href^='http']").each(function() {
var value = $(this).attr('href');
$(this).attr('href','<url>/pqr.php?'+value);
$(this).attr("target","_blank");
});
});
Works for me: http://jsfiddle.net/bontp6jk/
Upvotes: 1
Reputation: 267
How about this
$(document).ready(function(){
$("a").attr("target","_blank");
});
Upvotes: 0