2013-02-28 43 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 - 自定义图像计数器甚至自定义导航