一次性显示会话中的模式窗口

One time show modal window in session

本文关键字:模式 窗口 显示 会话 一次性      更新时间:2023-09-26

我只需要在第一次登录网站时显示一次模式窗口(引导程序)。我为什么不能那样做?

模式窗口

         <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="myModalLabel">Przeczytaj zanim zaczniesz!</h4>
                        </div>
                        <div class="modal-body">
     ..........................
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        </div>
                    </div>
                </div>
            </div>

JS-

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

简单地从服务器端在jsp中嵌入一个变量(idk是否使用框架);

request.setAttribute("isLoginPage", true);

并且假设您将jstl与jsp一起使用;

<script>
  <c:if test="${isLoginPage}">
    // your js code here
  </c:if>
</script>

您可以使用这里回答的java来获得相同的结果。

或者只使用javascript,或者您可以使用获取当前url;

var url = window.location.href;

并检查url是否为登录url。然而,这种方法在单页应用程序中不起作用。