Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 当我发送消息时,如何通知用户_Javascript_Asp.net_Internet Explorer_Firefox_Google Chrome - Fatal编程技术网

Javascript 当我发送消息时,如何通知用户

Javascript 当我发送消息时,如何通知用户,javascript,asp.net,internet-explorer,firefox,google-chrome,Javascript,Asp.net,Internet Explorer,Firefox,Google Chrome,有人知道弹出聊天窗口的代码吗。当我发送消息时,如何通知用户?如何使用户的窗口聚焦?或者闪烁弹出窗口。目前我有以下代码: function stateChangeHandler() { //readyState of 4 or 'complete' represents that data has been returned if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete') { //G

有人知道弹出聊天窗口的代码吗。当我发送消息时,如何通知用户?如何使用户的窗口聚焦?或者闪烁弹出窗口。目前我有以下代码:

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不工作。

我使用下面的JS文件作为弹出窗口,非常简洁

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

<div id="popupContact" runat="server" clientidmode="Static"></div>
<div id="backgroundPopup" runat="server" clientidmode="Static"></div>
您可以从页面本身调用这些。不过它是一个小的JS和CSS文件

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