du127953 2017-12-19 15:38
浏览 32
已采纳

刷新后的模态保持打开[关闭]

I am making a lockscreen with bootstrap modal (password validation) if user is idle then the modal is displayed but if user make a refresh of page then its removed and start counting again for user idle, i want if modal displayed and user make refresh to show again the modal for password validation

Any ideas?

<script type="text/javascript">

$.idleTimeout('#idletimeout', '#idletimeout a', {
    idleAfter: 5,
    pollingInterval: 2,
    keepAliveURL: '/keepAliveURL',
    serverResponseEquals: 'OK',
    onTimeout: function(){
    $(this).slideUp();

    document.getElementById('modal').click(); return false;


  },
    onIdle: function(){
        $(this).slideDown(); // show the warning bar
    },
    onCountdown: function( counter ){
        $(this).find("span").html( counter ); // update the counter
    },
    onResume: function(){
        $(this).slideUp(); // hide the warning bar
    }
});


</script>
  <button  type="button" class="btn btn-primary btn-lg" data-toggle="modal" id = "modal" data-target="#myModal"  style="display: none;">See Modal</button>


  <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false" >
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title" id="myModalLabel">Idle user</h4>
      </div>
      <div class="modal-body">

          <form id ="validationform" action="{{action('PatientsController@verifyuser',request()->route('id'))}}" method="post" >
            {{ csrf_field() }}
            @if ($errors->any())
            <div class="alert alert-danger">
                <ul>
                    @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach

                </ul>
            </div>
            @endif
            <label for="">Password</label>
          <p>  <input type="password" name="password" value="" required autofocus> <p>

            <button type="submit"  class="btn btn-default">Submit</button>

          </form>

</div>
  • 写回答

1条回答 默认 最新

  • drjv5597 2017-12-19 15:48
    关注

    You can do the following, say for example that you are using the Bootstrap modal:

    {validate here if you want to show the modal to the user}
    <script>
        $('#myModal').modal('show')
    </script>
    {validate here if you want to show the modal to the user}
    
    <!-- Modal Code Here -->
        <div...>
    <!-- Modal Code Here -->
    

    Here what you can do is validate that the user is inactive and through JS launch the event to show the modal to the user and deactivate that he can close it

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有没有可以帮我搞一个微信建群链接,包括群名称和群资料群头像那种,不会让你白忙
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题