简体   繁体   English

第一页加载时的引导模式

[英]Bootstrap modal at first page load

On page loading i am showing user some bootstrap modal window to show him some information.在页面加载时,我向用户展示了一些引导模式窗口,以向他展示一些信息。 I would like to show this bootstrap modal only on first time, then every one next should not.我只想在第一次展示这个引导模式,然后接下来的每个都不应该。 How to achieve that?如何做到这一点? Is there something like function disable after first time?第一次后是否有功能禁用之类的东西? This is my simple code:这是我的简单代码:

$(window).load(function () {
            $('#dddd').modal('show')
    });

This is a possible duplicate of this这可能是这个的重复

Nevertheless, you can use cookies to achieve this.不过,您可以使用 cookie 来实现这一点。 For your reference the following example is done using jquery cookie供您参考,以下示例是使用 jquery cookie 完成的

<script src="/path/to/jquery.cookie.js"></script>
<script>
    $(document).ready(function() {
        if ($.cookie(‘pop’) == null) {
            $(‘#dddd’).modal(‘show’);
            $.cookie(‘pop’, ’7');
        }
    });
</script>

add this to your js file:将此添加到您的 js 文件中:

if(window.sessionStorage.fist_load_modal1 === undefined){
    $('.first_load_modal').modal('show')
    window.sessionStorage.fist_load_modal1 = true
}

Now you can use the class 'first_load_modal' to show your modal on fist load.现在您可以使用“first_load_modal”类在第一次加载时显示您的模态。

<div class="modal fade first_load_modal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
         CONTENT HERE
        </div>
    </div>
</div>

Obs: Tested in bootstrap 4 Obs:在引导程序 4 中测试

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

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