0

I need show modal window (bootstrap) only one time, at first login to site. What I cant do that?

Modal window

         <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');
                });
Pekus
  • 155
  • 1
  • 6
  • 12

1 Answers1

0

Embed a variable in jsp from server side (idk whether you are using a framework) simply;

request.setAttribute("isLoginPage", true);

and assuming that you are using jstl along with jsp;

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

You can achive the same result with using java answered here.

Or only with javascript, alternatively you can get the current url with;

var url = window.location.href;

And check url whether is login url. However this approach does not work in single page applications.

Community
  • 1
  • 1
px5x2
  • 1,495
  • 2
  • 14
  • 29