• 用来给不愿意用iframe的同志的页面引用的解决办法


    说明:
      x系列是Hutia开发的系列JS代码,配合相应的css后可以实现快速的自定义标签
      目前xFrame支持的浏览器类型为:IE5.5, FF1.5(不完全,可能出现乱码)
      xFrame的标签为
        <div class="xFrame">
            <span class="xFrameSetting"> src="" interval="2000"</span>
              Loading...
          </div>
      
      支持属性:
        无
      支持方法:
        SetSrc(string URL), GetSrc(), SetInterval(int Interval), GetInterval()
        Refresh(), Stop()

    代码演示:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=gb2312" />
    <title>xFrame Demo</title>
    <style type="text/css">
    .xFrame {
     border:#00A 1px solid;
     padding:5px;
     margin:5px;
     95%;
     height:350px;
     font-size:12px;
     overflow:auto;
    }
    .xFrameSetting {
     display:none;

    </style>
    <script type="text/javascript">
    //<![CDATA[
    //********************/
    //  x 系列之 xFrame
    //  作者:Hutia
    //  未经同意不得转载或用于商业用途
    //********************/
    /*
    说明:
      x系列是Hutia开发的系列JS代码,配合相应的css后可以实现快速的自定义标签
      目前xFrame支持的浏览器类型为:IE5.5, FF1.5(不完全,可能出现乱码)
      xFrame的标签为
       <div class="xFrame">
        <span class="xFrameSetting"> src="" interval="2000"</span>
        Loading...
       </div>
     
      支持属性:
        无
      支持方法:
        SetSrc(string URL), GetSrc(), SetInterval(int Interval), GetInterval()
        Refresh(), Stop()
    */
    //**载入CSS*****
    var xFrameCssFilePath="sp\/css\/xframe.css";
    //document.write("<style>@import url("+xFrameCssFilePath+");</style>");
    //**检测浏览器种类*****
    var BROWSERNAME="";
    switch(navigator.appName.toLowerCase()){
     case "netscape":
      BROWSERNAME="ns";
     break;
     case "microsoft internet explorer":
     default:
      BROWSERNAME="ie";
     break;
    }
    //**设置初始化事件******
    switch(BROWSERNAME){
     case "ns":
      window.addEventListener("load",_xFrame_init,false);
     break;
     case "ie":
     default:
      window.attachEvent("onload",_xFrame_init);
    }
    //**确认需要的VBScript函数是否存在,不存在就写一个****
    try{
    if(typeof(rsB)=="undefined"){initVBS();};
    }catch(e){initVBS();}
    //**全局变量**
    //glbEncode储存ascii到unicode字符的转换,这样做的好处是可以提高重复解码时的解码效率
    glbEncode=new Array();
    //**设置全局定时器******
    if(typeof(__xSeriaTimer__)=="undefined"){
     var __xSeriaTimer__={
      events:new Array(),
      objs:new Array(),
      handle:null,
      times:0,
      interval:20,
      exec:function(){
       __xSeriaTimer__.times++;
       for(var i=0;i<__xSeriaTimer__.events.length;i++){
        try{
         with(__xSeriaTimer__.objs[i]){
          eval(__xSeriaTimer__.events[i]);
         }
        }catch(e){}
       }
      },
      pop:function(i){
       __xSeriaTimer__.events[i]=null;
       __xSeriaTimer__.objs[i]=null;
      },
      push:function(strV,obj){
       for(var i=0;i<__xSeriaTimer__.events.length;i++){
        if(__xSeriaTimer__.events[i]==null){
         __xSeriaTimer__.events[i]=strV;
         __xSeriaTimer__.objs[i]=obj;
         return(i);
        }
       }
       __xSeriaTimer__.events[i]=strV;
       __xSeriaTimer__.objs[i]=obj;
       return(i);
      },
      start:function(){
       __xSeriaTimer__.stop();
       __xSeriaTimer__.handle=setInterval(__xSeriaTimer__.exec,__xSeriaTimer__.interval);
      },
      stop:function(){
       clearInterval(__xSeriaTimer__.handle);
      }
     };
     __xSeriaTimer__.start();
    }
    //**初始化函数******
    function _xFrame_init(){
     var allTheFrames=document.getElementsByTagName("div");
     for(var i=0;i<allTheFrames.length;i++){
      if(allTheFrames[i].className=="xFrame")_xFrame_event_doInit(allTheFrames[i]);
     }
    }
    //**事件响应函数区******
    function _xFrame_event_doInit(element){
     //初始化变量
     element.xmlhttp=getXMLRequester();
     element._src="";
     element._interval=10000000;
     element._refreshTimeHandle=null;
     element._loadFinished=false;
     element.settingNode=getElementByClassName(element,"xFrameSetting");
     if(!element.settingNode){
      element.settingNode=document.createElement("div");
      element.settingNode.className="xFrameSetting";
      element.settingNode.xFrame=element;
      element.appendChild(element.settingNode);
     }
     
     //设置方法
     element.SetSrc=_xFrame_method_SetSrc;
     element.GetSrc=_xFrame_method_GetSrc;
     element.SetInterval=_xFrame_method_SetInterval;
     element.GetInterval=_xFrame_method_GetInterval;
     element.GetSetting=_xFrame_method_GetSetting;
     element.Refresh=_xFrame_method_Refresh;
     element.Stop=_xFrame_method_Stop;
     
     //设置事件
     element.Check=_xFrame_event_doCheck;
     element.Error=_xFrame_event_doError;
     
     //获取设置
     if(element.GetSetting("interval"))element.SetInterval(element.GetSetting("interval"));
     if(element.GetSetting("src"))element.SetSrc(element.GetSetting("src"));
    }
    function _xFrame_event_doCheck(){
     if(this._loadFinished)return(true);
     if(this.xmlhttp.readyState == 4){
      this._loadFinished=true;
      if(this.xmlhttp.status == 200) {//HTTP服务器响应的值OK
       switch(BROWSERNAME){
        case "ns":
         this.innerHTML=this.xmlhttp.responseText;
        break;
        case "ie":
        default:
         this.innerHTML=reCode(this.xmlhttp.responseBody);
       }
      }else{
       this.Error("Load failed".fontcolor("red"));
      }
     }
    }
    function _xFrame_event_doError(strErr){
     this.innerHTML=strErr;
    }
    //**方法函数区******
    function _xFrame_method_SetSrc(strSrc){
     if(typeof(strSrc)!="string")return(false);
     if(!strSrc.match(/^http:\/\//i))strSrc="http:\/\/"+strSrc;
     this._src=strSrc;
     this.Refresh();
    }
    function _xFrame_method_GetSrc(){
     return(this._src);
    }
    function _xFrame_method_SetInterval(interval){
     if(isNaN(interval)||interval==null||interval==""||interval<0)return(false);
     interval=parseInt(interval/__xSeriaTimer__.interval);
     interval=interval<1?1:interval;
     this._interval=interval;
    }
    function _xFrame_method_GetInterval(){
     return(this._interval);
    }
    function _xFrame_method_GetSetting(attributeName){
     var settingString=this.settingNode.innerHTML;
     if(!attributeName)return(settingString);
     var regE=new RegExp(attributeName+"=[ \t]*\"?([^\"]*)","i");
     var re=settingString.match(regE);
     if(re){
      return(re[1]);
     }else{
      return(re);
     }
    }
    function _xFrame_method_Refresh(){
     if(this._refreshTimeHandle!=null)this.Stop();
     this._loadFinished=false;
     try{
      this.xmlhttp.open('GET', this._src, true);
     }catch(e){this.Error("Load failed".fontcolor("red"));return(false);}
     this.xmlhttp.send(null);
     //this.xmlhttp.onreadystatechange=_xFrame_event_doChange;//不用这句因为无法在事件函数中引用xFrame
     this._refreshTimeHandle=__xSeriaTimer__.push("Check();if(__xSeriaTimer__.times%"+this._interval+"==0)Refresh();",this);
    }
    function _xFrame_method_Stop(){
     __xSeriaTimer__.pop(this._refreshTimeHandle);
     this._refreshTimeHandle=null;
    }
    //**通用函数区***
    function getXMLRequester( ){
     var xmlhttp_request = false;
     try{
      if( window.ActiveXObject ){
       for( var i = 5; i > -1; i-- ){
        try{
         if( i == 2 ){
          xmlhttp_request = new ActiveXObject( "Microsoft.XMLHTTP" );
         }else{
          xmlhttp_request = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" );
         }
         break;
        }catch(e){
         xmlhttp_request = false;
        }
       }
      }else if( window.XMLHttpRequest ){
       xmlhttp_request = new XMLHttpRequest();
      }
     }catch(e){
      xmlhttp_request = false;
     }
     return xmlhttp_request;
    }
    function getElementByClassName(obj,className){
     for(var i=0;i<obj.childNodes.length;i++){
      if(obj.childNodes[i].className==className)return(obj.childNodes[i]);
     }
     return(null);
    }
    //重编码
    function reCode(b){
     var t=rsB(b);
     t=escape(t).replace(/%u/g,"").replace(/(.{2})(.{2})/g,"%$2%$1").replace(/%([A-Z].)%(.{2})/g,"@$1$2");
     t=t.split("@");
     var i=0,j=t.length,k;
     while(++i<j)
     {
      k=t[i].substring(0,4);
      if(!glbEncode[k])glbEncode[k]=escape(vbChar(eval("0x"+k))).substring(1,6);
      t[i]=glbEncode[k]+t[i].substring(4);
     }
     return unescape(t.join("%"));
    }
    //**初始化函数**
    function initVBS(){
     //初始化VBscript的两个funtion:rsB 和 vbChar
     strVBS="<script language=vbscript>\r\n";
     strVBS+="Function rsB(vIn)\r\nrsB=MidB(vIn,1)\r\nEnd Function\r\n";
     strVBS+="Function vbChar(ss)\r\nvbChar = Chr(ss)\r\nEnd Function\r\n";
     strVBS+="<\/script>";
     document.write(strVBS);
    }
    //]]> 
    </script>
    </head>
    <body>
    <div class="xFrame">
     <span class="xFrameSetting"> src="http://bbs.blueidea.com/" interval="10000"</span>
     Loading...
    </div>
    </body>
    </html>

    =============================================================================================

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=gb2312" />
    <title>xFrame Demo</title>
    <script type="text/javascript" src="sp/js/xframe.js"></script>
    </head>
    <body>
    <div class="xFrame">
     <span class="xFrameSetting"> src="http://www.sina.com.cn" interval="10000"</span>
     Loading...
    </div>
    </body>
    </html>

    =============================================================================================

    //<![CDATA[
    //********************/
    //  x 系列之 xFrame
    //  作者:Hutia
    //  未经同意不得转载或用于商业用途
    //********************/
    /*
    说明:
      x系列是Hutia开发的系列JS代码,配合相应的css后可以实现快速的自定义标签
      目前xFrame支持的浏览器类型为:IE5.5, FF1.5(不完全,可能出现乱码)
      xFrame的标签为
       <div class="xFrame">
        <span class="xFrameSetting"> src="" interval="2000"</span>
        Loading...
       </div>
     
      支持属性:
        无
      支持方法:
        SetSrc(string URL), GetSrc(), SetInterval(int Interval), GetInterval()
        Refresh(), Stop()
    */
    //**载入CSS*****
    var xFrameCssFilePath="sp\/css\/xframe.css";
    document.write("<style>@import url("+xFrameCssFilePath+");</style>");
    //**检测浏览器种类*****
    var BROWSERNAME="";
    switch(navigator.appName.toLowerCase()){
     case "netscape":
      BROWSERNAME="ns";
     break;
     case "microsoft internet explorer":
     default:
      BROWSERNAME="ie";
     break;
    }
    //**设置初始化事件******
    switch(BROWSERNAME){
     case "ns":
      window.addEventListener("load",_xFrame_init,false);
     break;
     case "ie":
     default:
      window.attachEvent("onload",_xFrame_init);
    }
    //**确认需要的VBScript函数是否存在,不存在就写一个****
    try{
    if(typeof(rsB)=="undefined"){initVBS();};
    }catch(e){initVBS();}
    //**全局变量**
    //glbEncode储存ascii到unicode字符的转换,这样做的好处是可以提高重复解码时的解码效率
    glbEncode=new Array();
    //**设置全局定时器******
    if(typeof(__xSeriaTimer__)=="undefined"){
     var __xSeriaTimer__={
      events:new Array(),
      objs:new Array(),
      handle:null,
      times:0,
      interval:20,
      exec:function(){
       __xSeriaTimer__.times++;
       for(var i=0;i<__xSeriaTimer__.events.length;i++){
        try{
         with(__xSeriaTimer__.objs[i]){
          eval(__xSeriaTimer__.events[i]);
         }
        }catch(e){}
       }
      },
      pop:function(i){
       __xSeriaTimer__.events[i]=null;
       __xSeriaTimer__.objs[i]=null;
      },
      push:function(strV,obj){
       for(var i=0;i<__xSeriaTimer__.events.length;i++){
        if(__xSeriaTimer__.events[i]==null){
         __xSeriaTimer__.events[i]=strV;
         __xSeriaTimer__.objs[i]=obj;
         return(i);
        }
       }
       __xSeriaTimer__.events[i]=strV;
       __xSeriaTimer__.objs[i]=obj;
       return(i);
      },
      start:function(){
       __xSeriaTimer__.stop();
       __xSeriaTimer__.handle=setInterval(__xSeriaTimer__.exec,__xSeriaTimer__.interval);
      },
      stop:function(){
       clearInterval(__xSeriaTimer__.handle);
      }
     };
     __xSeriaTimer__.start();
    }
    //**初始化函数******
    function _xFrame_init(){
     var allTheFrames=document.getElementsByTagName("div");
     for(var i=0;i<allTheFrames.length;i++){
      if(allTheFrames[i].className=="xFrame")_xFrame_event_doInit(allTheFrames[i]);
     }
    }
    //**事件响应函数区******
    function _xFrame_event_doInit(element){
     //初始化变量
     element.xmlhttp=getXMLRequester();
     element._src="";
     element._interval=10000000;
     element._refreshTimeHandle=null;
     element._loadFinished=false;
     element.settingNode=getElementByClassName(element,"xFrameSetting");
     if(!element.settingNode){
      element.settingNode=document.createElement("div");
      element.settingNode.className="xFrameSetting";
      element.settingNode.xFrame=element;
      element.appendChild(element.settingNode);
     }
     
     //设置方法
     element.SetSrc=_xFrame_method_SetSrc;
     element.GetSrc=_xFrame_method_GetSrc;
     element.SetInterval=_xFrame_method_SetInterval;
     element.GetInterval=_xFrame_method_GetInterval;
     element.GetSetting=_xFrame_method_GetSetting;
     element.Refresh=_xFrame_method_Refresh;
     element.Stop=_xFrame_method_Stop;
     
     //设置事件
     element.Check=_xFrame_event_doCheck;
     element.Error=_xFrame_event_doError;
     
     //获取设置
     if(element.GetSetting("interval"))element.SetInterval(element.GetSetting("interval"));
     if(element.GetSetting("src"))element.SetSrc(element.GetSetting("src"));
    }
    function _xFrame_event_doCheck(){
     if(this._loadFinished)return(true);
     if(this.xmlhttp.readyState == 4){
      this._loadFinished=true;
      if(this.xmlhttp.status == 200) {//HTTP服务器响应的值OK
       switch(BROWSERNAME){
        case "ns":
         this.innerHTML=this.xmlhttp.responseText;
        break;
        case "ie":
        default:
         this.innerHTML=reCode(this.xmlhttp.responseBody);
       }
      }else{
       this.Error("Load failed".fontcolor("red"));
      }
     }
    }
    function _xFrame_event_doError(strErr){
     this.innerHTML=strErr;
    }
    //**方法函数区******
    function _xFrame_method_SetSrc(strSrc){
     if(typeof(strSrc)!="string")return(false);
     if(!strSrc.match(/^http:\/\//i))strSrc="http:\/\/"+strSrc;
     this._src=strSrc;
     this.Refresh();
    }
    function _xFrame_method_GetSrc(){
     return(this._src);
    }
    function _xFrame_method_SetInterval(interval){
     if(isNaN(interval)||interval==null||interval==""||interval<0)return(false);
     interval=parseInt(interval/__xSeriaTimer__.interval);
     interval=interval<1?1:interval;
     this._interval=interval;
    }
    function _xFrame_method_GetInterval(){
     return(this._interval);
    }
    function _xFrame_method_GetSetting(attributeName){
     var settingString=this.settingNode.innerHTML;
     if(!attributeName)return(settingString);
     var regE=new RegExp(attributeName+"=[ \t]*\"?([^\"]*)","i");
     var re=settingString.match(regE);
     if(re){
      return(re[1]);
     }else{
      return(re);
     }
    }
    function _xFrame_method_Refresh(){
     if(this._refreshTimeHandle!=null)this.Stop();
     this._loadFinished=false;
     try{
      this.xmlhttp.open('GET', this._src, true);
     }catch(e){this.Error("Load failed".fontcolor("red"));return(false);}
     this.xmlhttp.send(null);
     //this.xmlhttp.onreadystatechange=_xFrame_event_doChange;//不用这句因为无法在事件函数中引用xFrame
     this._refreshTimeHandle=__xSeriaTimer__.push("Check();if(__xSeriaTimer__.times%"+this._interval+"==0)Refresh();",this);
    }
    function _xFrame_method_Stop(){
     __xSeriaTimer__.pop(this._refreshTimeHandle);
     this._refreshTimeHandle=null;
    }
    //**通用函数区***
    function getXMLRequester( ){
     var xmlhttp_request = false;
     try{
      if( window.ActiveXObject ){
       for( var i = 5; i > -1; i-- ){
        try{
         if( i == 2 ){
          xmlhttp_request = new ActiveXObject( "Microsoft.XMLHTTP" );
         }else{
          xmlhttp_request = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" );
         }
         break;
        }catch(e){
         xmlhttp_request = false;
        }
       }
      }else if( window.XMLHttpRequest ){
       xmlhttp_request = new XMLHttpRequest();
      }
     }catch(e){
      xmlhttp_request = false;
     }
     return xmlhttp_request;
    }
    function getElementByClassName(obj,className){
     for(var i=0;i<obj.childNodes.length;i++){
      if(obj.childNodes[i].className==className)return(obj.childNodes[i]);
     }
     return(null);
    }
    //重编码
    function reCode(b){
     var t=rsB(b);
     t=escape(t).replace(/%u/g,"").replace(/(.{2})(.{2})/g,"%$2%$1").replace(/%([A-Z].)%(.{2})/g,"@$1$2");
     t=t.split("@");
     var i=0,j=t.length,k;
     while(++i<j)
     {
      k=t[i].substring(0,4);
      if(!glbEncode[k])glbEncode[k]=escape(vbChar(eval("0x"+k))).substring(1,6);
      t[i]=glbEncode[k]+t[i].substring(4);
     }
     return unescape(t.join("%"));
    }
    //**初始化函数**
    function initVBS(){
     //初始化VBscript的两个funtion:rsB 和 vbChar
     strVBS="<script language=vbscript>\r\n";
     strVBS+="Function rsB(vIn)\r\nrsB=MidB(vIn,1)\r\nEnd Function\r\n";
     strVBS+="Function vbChar(ss)\r\nvbChar = Chr(ss)\r\nEnd Function\r\n";
     strVBS+="<\/script>";
     document.write(strVBS);
    }
    //]]>

    ================================================================================

    .xFrame {
     border:#00A 1px solid;
     padding:5px;
     margin:5px;
     95%;
     height:350px;
     font-size:12px;
     overflow:auto;
    }
    .xFrameSetting {
     display:none;
    }

  • 相关阅读:
    k邻近
    C语言实现pwd—关于linux文件系统
    Linux多线程
    有关临时表
    毕设—线程池thread_pool(草)
    3-26
    3-25
    3-22
    关于中国神华
    3-20
  • 原文地址:https://www.cnblogs.com/buffer/p/1713409.html
Copyright © 2020-2023  润新知