简体   繁体   English

模态并打开新页面

[英]modal and open new page

I'm trying to open a modal and when you click on close button, it opens a url on same page. 我正在尝试打开一个模式,当您单击关闭按钮时,它会在同一页面上打开一个URL。 the code I'm using is: 我正在使用的代码是:

 $(document).ready(function() {
        //Show modal box
        $('#openModal').click(
            function() {$('.modal').show();}
        );
        //Hide modal box
        $('#closeModal').click(
            function() {$('.modal').hide();
            "location.href='http://google.com'";}
        );
    });

Someone? 有人吗 thanks in advance! 提前致谢!

The problem here is that the code to open the URL is inside double quotes. 这里的问题是打开URL的代码在双引号内。 The statement "location.href='http://google.com'"; 语句"location.href='http://google.com'"; does not do anything. 什么都不做。

You instead need: 相反,您需要:

$('#closeModal').click(function() {
    $('.modal').hide();
    location.href='http://google.com';
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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