include.js

// new prototype defintion
document.include = function (url) { 
 if ('undefined' == typeof(url)) return false;
 var p,rnd;
 if (document.all) {
  // For IE, create an ActiveX Object instance
  p = new ActiveXObject("Microsoft.XMLHTTP");
 }
 else {
  // For mozilla, create an instance of XMLHttpRequest.
  p = new XMLHttpRequest();
 }
 // Prevent browsers from caching the included page
 // by appending a random  number
 rnd = Math.random().toString().substring(2);
 url = url.indexOf('?')>-1 ? url+'&rnd='+rnd : url+'?rnd='+rnd;
 // Open the url and write out the response
 p.open("GET",url,false);
 p.send(null);
 document.write( p.responseText );
}

//Sam Add this function to fix P77 FireFox 3 RC2 issue at 6/24/2008
document.includeTo = function (url,elemId) { 
 if ('undefined' == typeof(url)) return false;
 var p,rnd;
 if (document.all) {
  // For IE, create an ActiveX Object instance
  p = new ActiveXObject("Microsoft.XMLHTTP");
 }
 else {
  // For mozilla, create an instance of XMLHttpRequest.
  p = new XMLHttpRequest();
 }
 // Prevent browsers from caching the included page
 // by appending a random  number
 rnd = Math.random().toString().substring(2);
 url = url.indexOf('?')>-1 ? url+'&rnd='+rnd : url+'?rnd='+rnd;
 // Open the url and write out the response
 p.open("GET",url,false);
 p.send(null);
 document.getElementById(elemId).innerHTML = p.responseText;
 
}

window["MzBrowser"]={};(function()
{
  if(MzBrowser.platform) return;
  var ua = window.navigator.userAgent;
  MzBrowser.platform = window.navigator.platform;

  MzBrowser.firefox = ua.indexOf("Firefox")>0;
  MzBrowser.opera = typeof(window.opera)=="object";
  MzBrowser.ie = !MzBrowser.opera && ua.indexOf("MSIE")>0;
  MzBrowser.mozilla = window.navigator.product == "Gecko";
  MzBrowser.netscape= window.navigator.vendor=="Netscape";
  MzBrowser.gecko = ua.indexOf('Gecko')>-1 && ua.indexOf('KHTML')==-1;
  MzBrowser.safari  = ua.indexOf("Safari")>-1;

  if(MzBrowser.firefox) var re = /Firefox(/s|//)(/d+(/./d+)?)/;
  else if(MzBrowser.ie) var re = /MSIE( )(/d+(/./d+)?)/;
  else if(MzBrowser.opera) var re = /Opera(/s|//)(/d+(/./d+)?)/;
  else if(MzBrowser.netscape) var re = /Netscape(/s|//)(/d+(/./d+)?)/;
  else if(MzBrowser.safari) var re = /Version(//)(/d+(/./d+)?)/;
  else if(MzBrowser.mozilla) var re = /rv(/:)(/d+(/./d+)?)/;

  if("undefined"!=typeof(re)&&re.test(ua))
    MzBrowser.version = parseFloat(RegExp.$2);
})();

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章