2013-02-28 41 views
0

所有打開另一個鏈接, 我有下面的代碼顯示一組Instagram的照片,然後我打開它們在我的網站的fancybox:使用標題在單獨的窗口

$output .= '<script type="text/javascript"> 
jQuery(document).ready(function($) { 
    $(".fancybox").fancybox(); 
}); 
</script>'; 

$output .= '<div id="bd-instagram">'; 

for($i=0; $i<$count; $i++){ 
    $output .= '<div class="bd-instagram-item"> 
    <a rel="instagram-widget" class="fancybox" title="This is a title" href="'.$images[$i]['image_large'].'"> 
    <img src="'.$images[$i]['image_small'].'" alt=""></a> 
    </div>'; 
} 

fancybox打開並在圖像下方顯示標題「這是一個標題」。不過,我真的想把它作爲一個鏈接,這樣當有人點擊標題時就會打開一個鏈接。我試圖做這樣的事情:

<a rel="instagram-widget" class="fancybox" title="<a href="http://www.instagram.com">Testing</a>" href="'.$images[$i]['image_large'].'"> 

雖然這並不工作,並在我的網頁上產生一些奇怪的HTML。有沒有人有任何想法如何做這樣的事情?

回答

1

嘗試在標題中對HTML進行編碼。例如,使用&lt;代替<符號。不知道這是否會奏效,但值得一試。

+0

這是正確的。我做了這樣的事情:< a href = " text.html " >你好</a >這增加了我的鏈接,它工作得很好! – user1048676 2013-02-28 04:02:36

0

Fancybox有一個titleFormat選項,您可以將其設置爲回調。我看到這個像:

function formatTitle(){ 
    return "<a href='http://instagram.com' target="_blank">test</a>"; 
} 

$(".fancybox").fancybox({ 
'titleFormat' : formatTitle 
}); 

我不知道我是對的,但documentation說:

titleFormat - 回調自定義標題區域。您可以設置任何html - 自定義圖像計數器甚至自定義導航