2010-09-05 42 views
2
$(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; 
    }); 

}); 

出於某種原因,在網站的一個嵌入式頁面上,這似乎會影響帶有onclick屬性的鏈接和圖像。任何想法爲什麼? (即使他們的目標是空白或頂部)。令人討厭的是,它似乎只能在一頁上完成。如何防止此代碼影響img onclick?

任何想法?

謝謝, 湯姆。

+0

可能是一個標籤未正確關閉在頁面上? – BGerrissen 2010-09-05 22:16:49

+0

不錯的主意,但他們正確關閉。 – Tom 2010-09-06 14:21:16

回答

0

嘗試排除其具有onclick屬性圖片/鏈接,使用:not選擇器的組合,並且所述has attribute選擇器:

$("a[href*='http://']:not([href='foo']):not([onclick])").attr("target","_blank"); 

演示:http://jsfiddle.net/HjYEX/2/

+0

不錯的主意,但仍然無法正常工作 – Tom 2010-09-06 14:23:00