简体   繁体   中英

How to open a modal on a new page

I need to know how to link from one page to another page. On second page I need to show a specific modal. Best Case is to show some specific category in the modal. Actually, the homepage link is dev.prdruck.com . From this page I want to link to a design gallery which is found under http://dev.prdruck.com/shirt-designer/?product_id=190&color=FFFFFF From this page, I can open the "Design Gallery" unter the button "Motive hinzufügen" which had the id #dg-cliparts . I tested the following but nothing happens...

I add the following at the end of the shirt-designer page:

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

But if i link to http://dev.prdruck.com/shirt-designer/#dg-cliparts nothing happens.

Maybe somebody had an idea? Thank you Junes

As you said it should work for you. Here when we click button new window with the ID of the modal will be open and the browser will get the # from the URL and will open the modal when window is loaded...!

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

Here urlHere is the url of the page on which you want to open the modal and myModal is the ID of the modal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM