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 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog