【发布时间】:2010-11-19 18:34:30
【问题描述】:
我有一个 JQuery UI 对话框,当用户访问我的网站时会自动打开,因此我们可以模态显示“正在建设”对话框。这是对话框的代码:
var $dialog = $('#dialog');
if ($.cookie("MySitePreviewCookie") != "firstView")
$(function () {
$.cookie("MySitePreviewCookie", "firstView", { expires: 180, path: '/' });
// Show Dialog Div
$dialog.dialog({
autoOpen: true,
resizable: false,
modal: true,
width: 600,
buttons: {
"Skip This": function () {
$(this).dialog("close");
}
}
});
});
else
$(function () {
// HIDE Dialog Div
$dialog.dialog({
autoOpen: false,
resizable: false,
modal: true,
width: 600,
buttons: {
"Skip This": function () {
$(this).dialog("close");
}
}
});
});
这是对话框标记:
<div id="dialog" title="Welcome to MySite" class="dialogStyles">
<p>
Our site is still under construction but please look around and get a feel for what
we plan to offer. If you would like to sign-up for our newsletter, please enter
your email address below and click the <strong>Sign-up for Newsletter</strong> button.
</p>
<p class="validateTips"></p>
<br />
<input type="text" id="ccEmailAddress" name="ccEmailAddress" class="required email"
style="width: 250px" />
<input id="btnAddNewsletter" class="submit" type="submit" value="Sign- up for Newsletter" />
</div>
对话框效果很好。我有 CSS 来设置它的样式,它看起来很棒,除了当页面第一次加载时有一堆图像显示在它后面的页面(主页)正在加载。它显示(位于页面的最底部),然后出现对话框,一切都很好。如何让它停止在页面上显示 DIV 而不影响对话框?
【问题讨论】:
-
你用过
style="display:none" -
出于好奇,如果您不打算显示它,为什么要创建一个对话框(我假设您只想在站点的第一个视图中显示它)?你甚至需要
else声明吗? -
你不想在页面加载时显示
-
哇,我就知道这很愚蠢。我想知道为什么我见过的演示从未显示过这个设置或在他们的样式表中。非常感谢!