MediaWiki:Common.js

MediaWiki:Common.js

出自白陽先天大道

在2009年2月17日 (二) 19:17由David (對話 | 貢獻)所做的修訂版本
(差異) ←上一修訂 | 當前修訂 (差異) | 下一修訂→ (差異)
跳轉到: 導航, 搜尋

注意: 在儲存以後, 您必須清除瀏覽器的快取才能看到所作出的改變。 Mozilla / Firefox / Safari: 按著 Shift 再點擊重新整理(或按下Ctrl-Shift-R,在蘋果Mac上按下Cmd-Shift-R);IE: 按著 Ctrl 再點擊 重新整理,或按下 Ctrl-F5Konqueror: 只需點擊 重新整理Opera: 使用者需要在 工具-設定 中完整地清除它們的快取。

/* 此處的JavaScript將載入於所有使用者每一個頁面。 */

/*** Place in MediaWiki:Common.js ****/
function makeRequest(url) {
  var httpRequest;				
 
  if (window.XMLHttpRequest) { // Mozilla, Safari, ...
      httpRequest = new XMLHttpRequest();
  } else if (window.ActiveXObject) { // IE
    try {
      httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {}
    }
  }
 
  if (!httpRequest) {
    alert("Giving up :( Cannot create an XMLHTTP instance");
    return false;
  }
  httpRequest.onreadystatechange = function() { alertContents(httpRequest); };
  httpRequest.open("GET", url, true);
  httpRequest.send(null);
}
 
function alertContents(httpRequest) {
 
  if (httpRequest.readyState == 4) {
    if (httpRequest.status == 200) {
        document.getElementById("p-calendar").innerHTML = httpRequest.responseText;
    } else {
        document.getElementById("p-calendar").innerHTML = "<p>There was a problem with the request.</p>";
    }
  }
}