0

有谁知道制作弹出聊天窗口的代码。发送消息时如何通知用户?如何让用户的窗口聚焦?或闪烁弹出窗口。目前我有这个代码:

function stateChangeHandler() {
    //readyState of 4 or 'complete' represents that data has been returned 
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete') {
        //Gather the results from the callback 
        var str = xmlHttp.responseText;
        if (str != "") {  
            var chatmsgs = eval(str);
            for (ind = 0; ind < chatmsgs.length; ind++) {
                var senderId = chatmsgs[ind].Sender;
                var chatId = chatmsgs[ind].ChatId;
                var message = chatmsgs[ind].Msg;
                var msgId = chatmsgs[ind].MsgId;

                message = restoreHtmlTags(message);
                document.getElementById('msgPanel').innerHTML += "<br><b>" + senderId + ": </b>" + message;
                MessageReceived(msgId, msgCounter);

                document.getElementById('msgPanel').scrollTop = document.getElementById('msgPanel').scrollHeight;
                window.focus();             

           }
        }
    }
}

它只在 Internet Explorer 中工作,Firefox 和 Chrome 不工作。

4

1 回答 1

0

我使用下面的 JS 文件弹出,非常简洁。

http://yensdesign.com/2008/09/how-to-create-a-stunning-and-smooth-popup-using-jquery/

在页面底部添加两个 div,例如

<div id="popupContact" runat="server" clientidmode="Static"></div>
<div id="backgroundPopup" runat="server" clientidmode="Static"></div>

在服务器端做这样的代码

popupContact.innerHTML = "your message";
ScriptManager.RegisterStartupScript(this, this.GetType(), "open", "centerPopup();loadPopup();", true);

您可以从页面本身调用这些。虽然它是小型 JS 和 CSS 文件。

于 2012-04-30T10:11:41.107 回答