SimpleModal——打开OnLoad
我是 JQuery 新手——对 javascript 并不陌生。
能够使用演示 index.html 页面中提供的超链接按钮打开 OSX 样式对话框,但希望在页面加载时打开它。我在 StackOverflow 上阅读了几个链接(How do我在页面加载时调用 SimpleModal OSX 对话框?),但仍然无法让它在完全相同的 index.html 页面中工作。我最终采取了权宜之计,通过以编程方式调用隐藏按钮元素的按钮单击 - 请参阅以下片段:
onLoad="document.getElementById('load_OSX_Example').click();">
<input type="hidden" id="load_OSX_Example" value="" class='osx'>
<script type="text/javascript" language="javascript">
//#### open the OSX Modal ##########
$(document).ready(function(){
$("#osx-modal-content").modal();
});
</script>
所以我有两个问题:
- 如何以编程方式使用 javascript/html 调用 class='osx' ?
- 为什么使用 $("#osx-modal-content").modal(); 不起作用?在 javascript 中调用(参见上面的片段)?我在多个浏览器中尝试过,屏幕上显示的唯一内容是这个标签的内容:“div id =“osx-modal-title”,并且jscript控制台中没有错误。
I'm new to JQuery -- not new to javascript.
Was able to open the OSX STYLE DIALOG using the hyperlink button provided in the demo index.html page, but would like to open it on the page load. I read a couple links on StackOverflow (How do I invoke a SimpleModal OSX dialog on page load?), but still could not get it to work in the exact same index.html page. I finally resorted to a stopgap measure by programmatically invoking the button click of a hidden button element -- see following fragment:
onLoad="document.getElementById('load_OSX_Example').click();">
<input type="hidden" id="load_OSX_Example" value="" class='osx'>
<script type="text/javascript" language="javascript">
//#### open the OSX Modal ##########
$(document).ready(function(){
$("#osx-modal-content").modal();
});
</script>
So I have two questions:
- How can you invoke the class='osx' using javascript/html programmatically?
- Why won't this work using the $("#osx-modal-content").modal(); call in javascript (see fragment above)? I tried this in multiple browsers, and the only content that displayed on the screen was content of this tag: "div id="osx-modal-title", and there was no error in the jscript console.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于#1:
对于#2,脚本如下:
确保包含示例中的图像/CSS 以获取样式。
For #1:
For #2, here's the script:
Make sure you include the images/CSS included in the sample to get the styling.
Bill,
如果您希望在页面加载时打开对话框,有几个选项。您可以直接编辑 osx.js 文件,也可以在加载 osx.js 文件后添加以下内容:
Bill,
If you want the dialog to open on page load, there are a couple of options. You can edit the osx.js file directly, or after you've loaded the osx.js file, add the following: