$(document).ready(function(){
$("a[href*='http://']:not([href*='开发者_运维技巧"+location.hostname+"'])").attr("target","_blank");
$("a[target!='_blank'][target!='_top']").live('click', function(){
$("#actualcontent").html('<center><img src="/deltasite/uploads/smallloader.gif"></center>');
var url=$(this).attr("href")+'?jquery=1';
$("#actualcontent").load(url);
$("#nav").load('/delta/pack_files/other/nav.php?url=' +$(this).attr("href"));
window.location.hash=$(this).attr("href");
return false;
});
});
For some reason, on one embedded page of the site, this seems to affect links and images with onclick attribute. Any idea why? (Even if their target is blank or top). It only seems to do it on one page, annoyingly.
Any ideas?
Thanks, Tom.
Try excluding images/links which have an onclick
attribute, using a combination of the :not
selector and the has attribute selector:
$("a[href*='http://']:not([href='foo']):not([onclick])").attr("target","_blank");
Demo: http://jsfiddle.net/HjYEX/2/
精彩评论