JavaScript window.onload和jQuery的$(document).ready()方法有什么区别?
我有一个带有bootstrap模式的页面(手册:http://getbootstrap.com/javascript/#modals).
我想在页面加载时打开这个模态.然而,这并没有发生.
<!-- Modal -->
<div class="modal fade" id="memberModal" tabindex="-1" role="dialog" aria-labelledby="memberModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="memberModalLabel">Thank you for signing in!</h4>
</div>
<div class="modal-body">
<p>However the account provided is not known.<BR>
If you just got invited to the group, please wait for a day to have the database synchronized.</p>
<p>You will now be shown the Demo site.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button> …Run Code Online (Sandbox Code Playgroud) 在Bootstrap中使用javascript显示模态对话框很容易.
但是如何在不需要document.ready函数或体onload函数的情况下使模态在页面加载时打开?
我需要加载页面并打开模态.页面加载时我不想要延迟或过渡效果.我希望模态在启动时打开.
我看了一下modal.js并尝试添加class="modal-open"身体没有任何效果.
<div class="modal in" id="journalModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">modal title</h4>
</div>
<div class="modal-body">
body
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
Run Code Online (Sandbox Code Playgroud)
可能吗?怎么做 ?
当一个人第一次访问某个页面时(我登录到我的应用程序后),我正在尝试显示一个bootstrap模式.我想使用模式提供"入门"视频,并提供"不再向我显示此复选框"复选框,以便访问者可以在将来登录时绕过"获取启动模式".
我能够通过以下教程获得在页面加载时显示的模态:
但是现在我只是在登录后第一次用户访问页面时才停止显示它(它目前在页面刷新等时启动)
我是javascript和编程的新手,并使用Django Python 2.7.4创建了我的应用程序
我非常感谢时间和专业知识.