在新窗口中打开当前图像



我正在尝试扩展fancybox,以允许一个新按钮在新窗口中打开当前图像。我计划通过onComplete添加这个,尽管我可以在API中找到解释如何从

获取当前图像的任何信息:
'onComplete' : function(currentArray, currentIndex, currentOpts){
    alert(currentArray.title);
}

或者你可以告诉我如何使用"currentArray, currentIndex, currentOpts"

Try this (demo):

CSS(我使用右箭头图标,但更改和/或移动这个图标,你想要的地方)

#external-link {
  position: absolute;
  top: -15px;
  right: 10px;
  width: 30px;
  height: 30px;
  background: transparent url('http://i56.tinypic.com/s5wupy.png') -40px -60px;
  cursor: pointer;
  z-index: 1103;
}
脚本

$('.popbox').fancybox({
  onComplete: function(currentArray, currentIndex, currentOpts){
    var currentUrl = currentArray[currentIndex].href,
      link = '<a target="_blank" id="external-link" title="Open in a new tab" href="' + currentUrl + '"></a>';
    $('#fancybox-close').before(link);
  }
});

最新更新