⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ajax.js

📁 关于ajax在web2.0中的应用(主要是实例程序)
💻 JS
📖 第 1 页 / 共 4 页
字号:
function emulateEventHandlers(eventNames) {
   for (var i = 0; i < eventNames.length; i++) {        
      document.addEventListener(eventNames[i], function (e) {
         window.event = e;
      }, true); // using capture
   }
}

ua = navigator.userAgent;
if ( ua.indexOf("Netscape") > 0 || ua.indexOf("Gecko") > 0 )
{
   emulateEventHandlers(["click", "mousemove"]);
}

function URLEncode( plaintext )
{
  // The Javascript escape and unescape functions do not correspond
  // with what browsers actually do...
  var SAFECHARS = "0123456789" +                                  // Numeric
                                        "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +  // Alphabetic
                                        "abcdefghijklmnopqrstuvwxyz" +
                                        "-_.!~*'()";                                    // RFC2396 Mark characters
  var HEX = "0123456789ABCDEF";
  var encoded = "";
  for (var i = 0; i < plaintext.length; i++ )
  {
    var ch = plaintext.charAt(i);
    if (ch == " ") {
                    encoded += "+";                             // x-www-urlencoded, rather than %20
    } else if (SAFECHARS.indexOf(ch) != -1) {
                    encoded += ch;
    } else {
                    var charCode = ch.charCodeAt(0);
                        if (charCode > 255) {
                            alert( "Unicode Character '" + ch + "' cannot be encoded using standard URL encoding.\n" +
                                        "(URL encoding only supports 8-bit characters.)\n" +
                                                "A space (+) will be substituted." );
                                encoded += "+";
                        } else {
                                encoded += "%";
                                encoded += HEX.charAt((charCode >> 4) & 0xF);
                                encoded += HEX.charAt(charCode & 0xF);
                        }
    }
  } // for

  return encoded;
};

function URLDecode( encoded )
{
   // Replace %xx with equivalent character
   var plaintext = "";
   var i = 0;
   while (i < (encoded.length-2))
   {
     var ch = encoded.charAt(i);
     if (ch == "+") {
               plaintext += " ";
                   i++;
     }
     else if (ch == "%" && encoded.charAt(i+1) != "%") {
       plaintext += unescape( encoded.substr(i,3) );
       i += 3;
     }
     else if (ch == "&" && encoded.charAt(i+1) == "#" && encoded.charAt(i+2) == "3" && encoded.charAt(i+3) == "4" && encoded.charAt(i+4) == ";")
     {
       plaintext += unescape( "%22" );
       i += 5;
     }
     else if (ch == "&" && encoded.charAt(i+1) == "#" && encoded.charAt(i+2) == "3" && encoded.charAt(i+3) == "9" && encoded.charAt(i+4) == ";")
     {
       plaintext += unescape( "%27" );
       i += 5;
     }
     else if (ch == "&" && encoded.charAt(i+1) == "#" && encoded.charAt(i+2) == "6" && encoded.charAt(i+3) == "0" && encoded.charAt(i+4) == ";")
     {
       plaintext += unescape( "%3C" );
       i += 5;
     }
     else if (ch == "&" && encoded.charAt(i+1) == "#" && encoded.charAt(i+2) == "1" && encoded.charAt(i+3) == "0" && encoded.charAt(i+4) == ";")
     {
       plaintext += unescape( "%0A" );
       i += 5;
     }
     else if (ch == "&" && encoded.charAt(i+1) == "#" && encoded.charAt(i+2) == "1" && encoded.charAt(i+3) == "3" && encoded.charAt(i+4) == ";")
     {
       plaintext += unescape( "%0D" );
       i += 5;
     }
     else {
       plaintext += ch;
       i++;
     }
   } // while
   if (i < encoded.length) {
            plaintext += encoded.substr(i,encoded.length-i);
   }
   return unescape(plaintext);
};

function floor(number)
{
  return Math.floor(number*Math.pow(10,2))/Math.pow(10,2);
} 
    
function markDirty(frm, elm, val)
{
  document.forms[frm].elements[elm].value=val;
}

function MM_goToURL() { //v3.0
    var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
    for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  var popWin = window.open(theURL,winName,features);
  popWin.opener = self;
  popWin.focus();
}

function OZ_openBrWindow(theURL,winName) { //v2.0
  var popWin = window.open(theURL,winName,'left=100,top=60,width=700,height=540,scrollbars=yes');
  popWin.opener = self;
  popWin.focus();
}

function OZ_openBrWin2(theURL,winName) { //v2.0
  var popWin = window.open(theURL,winName,'left=100,top=60,width=880,height=700,scrollbars=yes');
  popWin.opener = self;
  popWin.focus();
}

function OZ_openBrWin2WMenu(theURL,winName) { //v2.0
  var popWin = window.open(theURL,winName,'left=100,top=60,width=880,height=700,scrollbars=yes,menubar=yes');
  popWin.opener = self;
  popWin.focus();
}

function OZ_openBrWin3(theURL,winName) { //v2.0
  var popWin = window.open(theURL,winName,'left=10,top=10,width=900,height=680,scrollbars=yes');
  popWin.opener = self;
  popWin.focus();
}

function OZ_openBrWin4(theURL,winName) { //v2.0
  var popWin = window.open(theURL,winName,'left=100,top=60,width=880,height=540,scrollbars=yes');
  popWin.opener = self;
  popWin.focus();
}

function OZ_openBrWin5(theURL,winName) { // full screen
  var w = window.screen.availWidth;
  var h = window.screen.availHeight;
  var popWin = window.open(theURL,winName,' screenX=0,screenY=0,left=0,top=0,width='+w+',height='+h+',resizable=1,scrollbars=yes');
  popWin.opener = self;
  popWin.focus();
}


function MM_jumpMenu(targ,selObj,restore)
{
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenu2(targ,selObj,restore)
{
  var s = selObj.options[selObj.selectedIndex].value;
  if ( s.substring(0,1) != '_' )
  {
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  }
  else
  {
    s = s.substring(1, s.length);
    eval( s );
  }
}

function openLovPopup(fileName, lovName, formName, elmtName)
{
  var paramVal = document.forms[formName].elements[elmtName].value;
  var param = "?paramValue=" + paramVal;

  var lovWin = window.open( fileName + param, lovName, 'width=720,height=500,scrollbars=yes');
    lovWin.opener = self;
    lovWin.focus();
}

function openLovPopupWParam(fileName, lovName, formName, elmtName)
{
  var paramVal = document.forms[formName].elements[elmtName].value;
  var param = "&paramValue=" + paramVal;

  var lovWin = window.open( fileName + param, lovName, 'width=720,height=500,scrollbars=yes');
    lovWin.opener = self;
    lovWin.focus();
}

var openCalV2FieldID;
var openCalV2FormID;
function openCalV2( formname, fieldid )
{
  openCalV2FormID  = formname;
  openCalV2FieldID = fieldid;
  opencal2( document.forms[openCalV2FormID].elements[openCalV2FieldID].value );
}
function acceptDateV2(dayStr)
{
  document.forms[openCalV2FormID].elements[openCalV2FieldID].value = dayStr;
}

function getBrowserSizeX() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  }
  else
  {
    if( document.documentElement &&
        ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      myWidth = document.documentElement.clientWidth;
    }
    else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
      myWidth = document.body.clientWidth;
    }
  }
  return myWidth;
}

function getBrowserSizeY() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  }
  else
  {
    if( document.documentElement &&
        ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
      myHeight = document.body.clientHeight;
    }
  }
  return myHeight;
}

function Toggle(item) {
   //added by janet 2005.11.7 ---begin
   var max=item+"_max";
   var min=item+"_min";
   objMax=document.getElementById(max);
   objMin=document.getElementById(min);
   //added by janet 2005.11.7 ---end
   obj=document.getElementById(item);

   visible=(obj.style.display!="none")  
   if (visible) {
     obj.style.display="none";
     //added by janet 2005.11.7 ---begin
     if ( objMax != null ) objMax.style.display="block";
     if ( objMin != null ) objMin.style.display="none";
     //added by janet 2005.11.7 ---end
   } else {
     obj.style.display="block";
     //added by janet 2005.11.7 ---begin
     if ( objMax != null ) objMax.style.display="none";
     if ( objMin != null ) objMin.style.display="block";
     //added by janet 2005.11.7 ---end
   }
}
function ToggleSet(item,val) {
   obj=document.getElementById(item);
   obj.style.display=val;
}

var IFrameObj; // our IFrame object
var _backgroundURL;
function jsCallToServer(backgroundURL)
{
  if (!document.createElement)
  {
    return true;
  }
  
  var IFrameDoc;
  _backgroundURL =  backgroundURL;
  if (!IFrameObj && document.createElement)
  {
    // create the IFrame and assign a reference to the object to our global variable IFrameObj.
    // this will only happen the first time callToServer() is called
    try
    {
               var tempIFrame=document.createElement('iframe');
               tempIFrame.setAttribute('id','RSIFrame');
               tempIFrame.src='z0.jsp';
               tempIFrame.style.border='0px';
               tempIFrame.style.width='0px';
               tempIFrame.style.height='0px';
               IFrameObj = document.body.appendChild(tempIFrame);
               
               if (document.frames)
               {// this is for IE5 Mac, because it will only allow access to the document object
               // of the IFrame if we access it through the document.frames array
                    IFrameObj = document.frames['RSIFrame'];
               }
    }
    catch(exception)
    {
        // This is for IE5 PC, which doesn't allow dynamic creation/manipulation of iframe object.
               // Instead, we'll fake it up by creating our own objects.
               iframeHTML='\<iframe id="RSIFrame" src="z0.jsp" style="';
               iframeHTML+='border:0px;';
               iframeHTML+='width:0px;';
               iframeHTML+='height:0px;';
               iframeHTML+='"><\/iframe>';
               document.body.innerHTML+=iframeHTML;
               IFrameObj = new Object();
               IFrameObj.document = new Object();
               IFrameObj.document.location = new Object();
               IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
               IFrameObj.document.location.replace = function(location) {this.iframe.src = location;}
    }
  }          


  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument)
  {
    // we have to give NS6 a fraction of a second
    // to recognize the new IFrame
    setTimeout('jsCallToServer()',10);
    return false;
  }
 
  if (IFrameObj.contentDocument)
  {     // For NS6
          IFrameDoc = IFrameObj.contentDocument;
  }
  else if (IFrameObj.contentWindow)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -