2009-07-09 38 views
2

我正在使用jQuery Fancybox plugin創建一個模式窗口,鏈接的內容爲href,標題爲title。我希望能夠在標題中添加一個可點擊的鏈接(在這種情況下可以生成較大的地圖),但我無法將<a>標記添加到title屬性中。我該如何通過Javascript,jQuery或其他方法來實現這個鏈接?我可以在標題屬性中加入鏈接嗎?

<a class='iframe' href='http://maps.google.com/maps?q=%235+Health+Department+Drive,+Troy,+MO+63379&amp;ll=38.979228,-90.97847&amp;z=13&amp;iwloc=near&amp;num=1&amp;output=embed' title='Google Map to Lincoln County Health Department'>Map to LCHD</a> 

What it looks like http://i31.tinypic.com/i6frq1.png

回答

2

我不熟悉這個插件,但這種方法浮現在腦海。

您可以將內容元素埋入錨點並修改插件以使用您引入的元素。例如:

<a class='iframe' 
    href='http://maps.google.com/blahlblahlbah' 
    title='Google Map to Lincoln County Health Department'>Map to LCHD 
    <span class="title-href" style="display: none">http://zebrakick.com</span> 
</a> 

希望有幫助。

0

也許不是最好的建議,但你可以讓你自己的屬性附加傷害,也許像這樣

<a class='iframe' href='http://maps.google.com/maps?q=%235+Health+Department+Drive,+Troy,+MO+63379&amp;ll=38.979228,-90.97847&amp;z=13&amp;iwloc=near&amp;num=1&amp;output=embed' title='Google Map to Lincoln County Health Department' dest="/path/to/file.ext">Map to LCHD</a> 
0

保持元素=> DESTINATION_LINK映射爲對象,並從獲取值它用於重定向。

var linkmap = { 
    lincoln: '/location/3/', 
    someplace: '/location/99' 
} 

現在你可以使用從linkmap值在點擊事件(用[]或。運營商)

0

我通過額外的數據與一起:

<a href="images/product.jpg" title="Product nummer 1" data-title-url="http://google.nl" rel="fancybox"> 

,並使用了自定義的回調設置標題:

{ 
    //fancybox options array 
    titleFormat: function(title, currentArray, currentIndex, currentOpts){ 
     var currentElement = currentArray[currentIndex]; 

     var html = "<h1>" + title + "</h1>"; 
     var titleUrl = $(currentElement).data("title-url"); 
     if (titleUrl) { 
      var link = $("<a>", {href: titleUrl, text: titleUrl, target: "_blank"}); 
      html += " (" + link.prop("outerHTML") + ")"; 
     } 

     return html; 
    }, 
} 

http://fancybox.net/api

http://api.jquery.com/data/

相關問題