2009-07-09 80 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/

相关问题