1. 程式人生 > >DevExpress與長連線衝突導致DevExpressAJax事件失效

DevExpress與長連線衝突導致DevExpressAJax事件失效

最近公司要做一個長連線從伺服器推送訊息,網上找了一段程式碼

      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();
}