如何在页面加载时调用 SimpleModal OSX 对话框?
我想知道是否有办法在页面加载时调用 SimpleModal OSX 对话框? 我尝试 在页面加载时打开 jquery 模式对话框 但无法让它发生。
目前,单击按钮/链接即可调用该对话框。我想在页面加载时调用它。
请帮忙。 :)
谢谢!
<script type='text/javascript' src='js/jquery.js'></script>
<script type='text/javascript' src='js/jquery.simplemodal.js'></script>
<script type='text/javascript' src='js/osx.js'></script>
<input type='button' name='osx' value='Demo' class='osx demo'/> or <a href='#' class='osx'>Demo</a>
<div id="osx-modal-content">
<div id="osx-modal-data">
<h2>Hello! I'm SimpleModal!</h2>
<p><button class="simplemodal-close">Close</button> <span>(or press ESC or click the overlay)</span></p>
</div>
</div>
I was wondering if there is a way to invoke the SimpleModal OSX dialog box on page load?
I tried open jquery modal dialog on page load but wasn't able to make it happen.
Currently, the dialog is invoked on clicking a button / link. I would like to invoke it on page load.
Please help. :)
Thanks!
<script type='text/javascript' src='js/jquery.js'></script>
<script type='text/javascript' src='js/jquery.simplemodal.js'></script>
<script type='text/javascript' src='js/osx.js'></script>
<input type='button' name='osx' value='Demo' class='osx demo'/> or <a href='#' class='osx'>Demo</a>
<div id="osx-modal-content">
<div id="osx-modal-data">
<h2>Hello! I'm SimpleModal!</h2>
<p><button class="simplemodal-close">Close</button> <span>(or press ESC or click the overlay)</span></p>
</div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这部分取自您引用的问题,应该可以解决问题:
在 DOM 加载后立即调用
.ready()
函数。如果这不起作用,但单击按钮有效,我只能猜测代码的某些部分尚未加载,这对于对话框至关重要。尝试查看 javascript 中出现的错误。所有现代浏览器都允许您这样做。
This part taken from the question you referenced should do the trick:
The
.ready()
function is invoked just after the DOM has loaded. If this doesn't work but clicking on your button works I can only guess that some part of the code hasn't loaded yet that is essential for a dialog.Try looking at the errors you get from your javascript. All modern browsers let you do that.
您应该将该代码添加到本部分的 osx.js 脚本中:
You should add that code into osx.js script in this part: