最近公司要做一个长连接从服务器推送消息,网上找了一段代码
function onload() {
var isIE = !!window.ActiveXObject;
if (isIE) {
ifrpush = new ActiveXObject("htmlfile"); // 创建对象
ifrpush.open(); //打开
var ifrDiv = ifrpush.createElement("div"); //添加一个DIV
ifrpush.appendChild(ifrDiv); //添加到 htmlfile
ifrpush.parentWindow.Change = Change; //注册 javascript 方法
ifrDiv.innerHTML = "<iframe src='Action/Socket.ashx'></iframe>"; //在div里添加 iframe
ifrpush.close(); //关闭
setInterval("IsLoaded()", 1000); //监视长链接状态
} else {
request = new window.XMLHttpRequest();
responseDIV.innerHTML = "";
var url = "Action/Socket.ashx";
request.open("GET", url, true);
request.onreadystatechange = NOTIEReadyStateChange;
request.send(null);
}
}
结果的DevExpress的js方法名重复了
_aspxAttachEventToElement(window, "load", aspxClassesWindowOnLoad); function aspxClassesWindowOnLoad(evt){ __aspxDocumentLoaded = true; ASPxResourceManager.SynchronizeResources(); aspxGetControlCollection().Initialize(); _aspxInitializeScripts(); _aspxInitializeLinks(); _aspxInitializeFocus(); }