【问题标题】:How to use lightbox plug-in instead of window.open?如何使用灯箱插件代替window.open?
【发布时间】:2015-04-17 14:03:24
【问题描述】:

在我的 JavaScript 代码中,它会打开一个带有打开函数/方法的新窗口。

window.open("sample_link");

但我既不想打开选项卡也不想打开窗口。我发现了很多作用于元素的示例灯箱插件。我可以在我的 JavaScript 代码中使用灯箱插件的函数/方法而不是 open 函数吗? (不在 html 文件中)

【问题讨论】:

    标签: javascript jquery html lightbox lightbox2


    【解决方案1】:

    不,你不能。这个插件处理用户交互。如果您想以编程方式打开 灯箱,您可以尝试:

    <a  href="img/image-1.jpg" data-lightbox="image-1" data-title="My caption">Image #1</a>
    
    $('[data-lightbox]')[i].click();
    // where i is the element you want
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-16
      • 1970-01-01
      • 1970-01-01
      • 2013-01-27
      • 1970-01-01
      • 2020-03-02
      • 1970-01-01
      • 2012-10-18
      相关资源
      最近更新 更多