1

我正在使用 JQuery 的对话框在用户访问页面时弹出一条消息,但它应该每天只发生一次。我已经设法让一切正常,但是当代码命中时:

$('#dialog').dialog('open')

没发生什么事。现在当我这样做时:

modal: true,

运行它,背景覆盖确实出现了,但不是实际的对话框。我读了一个问题,他们说这是一个错误并注释掉了某行,我这样做了,但没有发生任何变化。

它在 chrome、ff 等中效果很好,只是在 IE8 中不行

这是我的代码(当然只是相关的东西):

<script src="http://testsite/JQuery/js/jquery-1.8.0.min.js" ></script>
<script src="http://testsite/JQuery/development-bundle/ui/jquery.ui.core.js"></script>
<script src="http://testsite/JQuery/jquery-ui-1.8.20.custom/development-bundle/ui/jquery.ui.widget.js"></script>
<script src="http://testsite/JQuery/jquery-ui-1.8.20.custom/development-bundle/ui/jquery.ui.position.js"></script>
<script src="http://testsite/JQuery/jquery-ui-1.8.20.custom/development-bundle/ui/jquery.ui.dialog.js"></script>

<link rel="stylesheet" href="JQuery/jquery-ui-1.8.20.custom/css/ui-lightness/jquery-ui-1.8.20.custom.css" type="text/css">

<script type="text/javascript">

function openpopup() {
    $("#dialog").dialog('open');
}

function writeCookieTest() {
    var currentDate = new Date();
    currentDate.setTime(currentDate.getTime() + 60 * 1000); // Just a minute to test
    document.cookie = "oncePerDay=true; expires=" + currentDate.toGMTString() + "; path=/";
}

function readCookieTest() {
    var name = "oncePerDay";
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

$(document).ready(function () {

    $("#dialog").dialog({
        autoOpen: false,
        modal: true,
        height: 300,
        width: 300
    });

    if (readCookieTest() != "true") {
        writeCookieTest();
        openpopup();
    }
});
</script>



<div id="dialog" title="Reminder!">
<p>This is the text to remind...</p>
</div>
4

1 回答 1

0

解决了。没有所有需要的脚本和混合脚本版本似乎是一个问题,以下 jQuery 脚本允许对话框在 IE8 上正常工作:

<link rel="stylesheet" href="jQueryUI/jquery-ui-1.8.21.custom.css">

<script src="jQueryUI/jquery-1.7.2.min.js"></script>
<script src="jQueryUI/jquery.ui.core.js"></script>
<script src="jQueryUI/jquery.ui.datepicker.js"></script>
<script src="jQueryUI/jquery.ui.widget.js"></script>
<script src="jQueryUI/jquery.ui.position.js"></script>
<script src="jQueryUI/jquery.ui.dialog.js"></script>
<script src="jQueryUI/jquery.ui.mouse.js"></script>
<script src="jQueryUI/jquery.ui.draggable.js"></script>
<script src="jQueryUI/jquery.effects.core.js"></script>
<script src="jQueryUI/jquery.effects.explode.js"></script>
<script src="jQueryUI/jquery.ui.resizable.js"></script>
于 2012-08-21T19:12:17.920 回答