如何从jquery插件中删除x按钮

时间:2012-06-03 18:40:17

标签: javascript jquery jquery-plugins plugins

我有一个应用程序here,如果你在约20秒内没有做任何事情,它会显示一个空闲超时插件消息,说明你是想要继续还是注销。

问题是它在角落的顶部按钮上显示一个x按钮,如果用户点击x按钮,消息就会消失,但是在选项卡中,计时器仍然会继续。

那么我的问题是如何删除邮件顶角的x按钮?

以下是该应用程序的代码:

<head>
<script type="text/javascript">

$(document).ready(function()

{

    $("#dialog").dialog({
    autoOpen: false,
    modal: true,
    width: 400,
    height: 200,
    closeOnEscape: false,
    draggable: false,
    resizable: false,
    buttons: {
        'Yes, Keep Working': function(){
            // Just close the dialog. We pass a reference to this
            // button during the init of the script, so it'll automatically
            // resume once clicked
            $(this).dialog('close');
        },
        'No, Logoff': function(){
            // fire whatever the configured onTimeout callback is.
            $.idleTimeout.options.onTimeout.call(this);
        }
    }
});


$.idleTimeout('#dialog', 'div.ui-dialog-buttonpane button:first', {
    idleAfter: 5, // user is considered idle after 5 minutes of no movement
    pollingInterval: 60, // a request to keepalive.php (below) will be sent to the server every minute
    onTimeout: function(){

        // redirect the user when they timeout.
        window.location = "timeout.htm";

    },
    onIdle: function(){

        // show the dialog when the user idles
        $(this).dialog("open");

    },
    onCountdown: function(counter){

        // update the counter span inside the dialog during each second of the countdown
        $("#dialog-countdown").html(counter);

    },
    onResume: function(){

        // the dialog is closed by a button in the dialog
        // no need to do anything else

    }
});

});


</script>

</head>

<body>

<div id="dialog" title="Your session is about to expire!">
    <p>You will be logged off in <span id="dialog-countdown"></span> seconds.</p>
    <p>Do you want to continue your session?</p>
</div>
</body>
</html>

2 个答案:

答案 0 :(得分:1)

打开对话框时可以隐藏X.

$("#div2").dialog({
   closeOnEscape: false,
   open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); }
}); 

Here is the original SO question and answer

答案 1 :(得分:0)

或者只是放一个

<style>
     .ui-dialog-titlebar-close { display: none ; }
</style>