2015-11-24 30 views
0

我只需要一次顯示模態窗口(bootstrap),首先登錄到站點。 我不能這樣做?有一次在會話中顯示模態窗口

模態窗口

  <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'); 
       }); 

回答

0

嵌入在從服務器端jsp變量(IDK是否要使用的框架)簡單地;

request.setAttribute("isLoginPage", true); 

並假設您正在使用jstl和jsp;

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

你可以使用java實現相同的結果回答here

或者只有javascript,或者你可以得到當前的網址;

var url = window.location.href; 

並檢查網址是否爲登錄網址。但是,這種方法在單頁面應用程序中不起作用。