function Ajax(){
             
                       //    doc.innerHTML='<span><img src="image/load.gif"/>Loading...</span>';
                      ////創(chuàng)造對(duì)象
                      var xmlhttp;
                      try
                      {
                          if (window.ActiveXObject){
                              /* 不要?jiǎng)h除以下注釋,這部分不是注釋 */
                              /*@cc_on @*/
                              /*@if (@_jscript_version >= 5)
                              try {
                                xmlhttp = new ActiveXObject("Msxml2.xmlhttp");
                              } catch (e) {
                                try {
                                  xmlhttp = new ActiveXObject("Microsoft.xmlhttp");
                                } catch (e) {
                                  xmlhttp = false;
                                }
                              }
                              @end @*/
                          }else{
                              xmlhttp=new XMLHttpRequest();
                          }
                          if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
                            xmlhttp = new XMLHttpRequest();
                          }
                      }
                      catch(e)
                      {
                      alert(e.message);
                      }
                      //alert(xmlhttp);
                      if(!xmlhttp)
                      {
                      alert("你的瀏覽器不支持xmlhttp對(duì)象,所以一些功能無法使用,建議使用高版本的瀏覽器!!");
                      return;
                      }

          //    
                      ///函數(shù)主題
                          this.getData=function(url,data,dodata)
                          {
                              var verbs =data;
                             // alert(data);
                              xmlhttp.open("POST", url,true);

                                  xmlhttp.onreadystatechange=function(){
                                      if (xmlhttp.readyState==4){
                                          dodata(xmlhttp);                 
                                      }
                                  }
                              xmlhttp.setRequestHeader("Content-Length",verbs.length);
                              xmlhttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
                              xmlhttp.send(verbs);
                          }
                          /////
                          this.getUrlData=function(url,data,dodata)
                          {
                              xmlhttp.open("GET",url,true);

                              xmlhttp.onreadystatechange = function() {

                              if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                                dodata(xmlhttp);
                               Status.setStatusShow(false);
                              }
                              else
                              {
                                Status.showInfo("加載中...");
                              }
                           
                              }
                               xmlhttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
                              xmlhttp.send(null);
                          }
                          this.getFormData=function(demo)
                          {
                          alert(demo);
                          }
                      ///函數(shù)主題
          }
          /**
           * @author zxub 2006-06-01
           * 狀態(tài)信息顯示類,用var Status=new function()定義,可以靜態(tài)引用其中的方法
           * 一般情況下為function Status(),這樣不能靜態(tài)引用其中的方法,需要通過對(duì)象來引用
           */
          var Status=new function()
          {
              this.statusDiv=null;
             
              /**
               * 初始化狀態(tài)顯示層
               */
           this.init=function()
           {
               if (this.statusDiv!=null)
               {
                   return;
               }
            var body = document.getElementsByTagName("body")[0];
            var div = document.createElement("div");
            div.style.position = "absolute";
            div.style.top = "50%";
            div.style.left = "50%";
            div.style.width = "280px";
            div.style.margin = "-50px 0 0 -100px";  
            div.style.padding = "15px";
            div.style.backgroundColor = "#353555";
            div.style.border = "1px solid #CFCFFF";
            div.style.color = "#CFCFFF";
            div.style.fontSize = "14px";
            div.style.textAlign = "center";
            div.id = "idstatus";
            body.appendChild(div);
            div.style.display="none";
            this.statusDiv=document.getElementById("idstatus");
           }
           
           /**
            * 設(shè)置狀態(tài)信息
            * @param _message:要顯示的信息
            */ 
           this.showInfo=function(_message)
           {  
               if (this.statusDiv==null)
               {
                   this.init();
               } 
               this.setStatusShow(true);
               this.statusDiv.innerHTML = _message;    
           }
           
           /**
            * 設(shè)置狀態(tài)層是否顯示
            * @param _show:boolean值,true為顯示,false為不顯示
            */
           this.setStatusShow=function(_show)
           {  
               if (this.statusDiv==null)
               {
                   this.init();
               }
               if (_show)
               {
                   this.statusDiv.style.display="";
               }
               else
               {
                   this.statusDiv.innerHTML="";
                   this.statusDiv.style.display="none";
               }
           }
          }
          function GetPosition(element) {
              var result = new Object();
              result.x = 0;
              result.y = 0;
              result.width = 0;
              result.height = 0;
              if (element.offsetParent) {
                  result.x = element.offsetLeft;
                  result.y = element.offsetTop;
                  var parent = element.offsetParent;
                  while (parent) {
                      result.x += parent.offsetLeft;
                      result.y += parent.offsetTop;
                      var parentTagName = parent.tagName.toLowerCase();
                      if (parentTagName != "table" &&
                          parentTagName != "body" &&
                          parentTagName != "html" &&
                          parentTagName != "div" &&
                          parent.clientTop &&
                          parent.clientLeft) {
                          result.x += parent.clientLeft;
                          result.y += parent.clientTop;
                      }
                      parent = parent.offsetParent;
                  }
              }
              else if (element.left && element.top) {
                  result.x = element.left;
                  result.y = element.top;
              }
              else {
                  if (element.x) {
                      result.x = element.x;
                  }
                  if (element.y) {
                      result.y = element.y;
                  }
              }
              if (element.offsetWidth && element.offsetHeight) {
                  result.width = element.offsetWidth;
                  result.height = element.offsetHeight;
              }
              else if (element.style && element.style.pixelWidth && element.style.pixelHeight) {
                  result.width = element.style.pixelWidth;
                  result.height = element.style.pixelHeight;
              }
              return result;
          }

          posted on 2009-10-28 16:03 sanmao 閱讀(803) 評(píng)論(2)  編輯  收藏

          FeedBack:
          # re: ajax|消息提示框|js獲取html絕對(duì)位置 封裝
          2011-11-15 09:32 | 長春網(wǎng)站設(shè)計(jì)
          按照博主說的,回去試試  回復(fù)  更多評(píng)論
            
          # re: ajax|消息提示框|js獲取html絕對(duì)位置 封裝
          2011-11-15 09:33 | 長春網(wǎng)站設(shè)計(jì)
          不知道、能不能行  回復(fù)  更多評(píng)論
            

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 呼伦贝尔市| 天水市| 滨州市| 汤阴县| 明水县| 习水县| 梨树县| 麻江县| 闽清县| 齐齐哈尔市| 崇信县| 江山市| 固镇县| 镇赉县| 鄂托克旗| 宁津县| 永新县| 鄱阳县| 抚远县| 古田县| 云和县| 紫阳县| 自治县| 新密市| 馆陶县| 那曲县| 汝州市| 紫阳县| 兴化市| 县级市| 巴林左旗| 贵定县| 康平县| 华容县| 临夏县| 丽水市| 鹿邑县| 吉安市| 建湖县| 滁州市| 洞头县|