如何在新页面上打开模态

时间:2017-08-01 11:53:28

标签: javascript jquery wordpress twitter-bootstrap

我需要知道如何从一个页面链接到另一个页面。在第二页,我需要显示一个特定的模态。最佳案例是在模态中显示某些特定类别。 实际上,主页链接是dev.prdruck.com。在此页面中,我想链接到http://dev.prdruck.com/shirt-designer/?product_id=190&color=FFFFFF下的设计图库 在这个页面中,我可以打开“设计图库”,打开ID为#dg-cliparts的按钮“Motivehinzufügen”。 我测试了以下但没有任何反应......

我在衬衫设计师页面的末尾添加以下内容:

 $(document).ready(function(){var modals = ['#dg-cliparts']; if(window.location.hash&& ~modals.indexOf(window.location.hash)){$(window .location.hash).modal();}})

但如果我链接到http://dev.prdruck.com/shirt-designer/#dg-cliparts没有任何反应。

也许有人有想法? 谢谢 Junes

1 个答案:

答案 0 :(得分:0)

正如你所说它应该适合你。这里当我们点击按钮时,新窗口将显示模态的ID,浏览器将从URL获取#并在窗口加载时打开模态...!

$(document).ready(function () {
    $('.btn').on('click', function (event) {
        event.preventDefault();
        window.open(urlHere + '#myModal', '');
    });
    $(window).load(function () {
        $(window.location.hash).modal("show");
    });
});

此处urlHere是您要打开模式的网页的网址,myModal是模式的ID。

相关问题