Solutions used to reference pages of comrades who are unwilling to use IFRAME

Source: Internet
Author: User
Tags recode

Note:
The X series is the JS series developed by Hutia.CodeWith the corresponding CSS, you can quickly customize tags.
Currently, xframe supports ie5.5 and ff1.5 browsers (incomplete, garbled characters may occur)
The xframe label is
<Div class = "xframe">
<SPAN class = "xframesetting"> src = "" interval = "2000" </span>
Loading...
</Div>

Supported attributes:
None
Supported methods:
Setsrc (string URL), getsrc (), setinterval (INT interval), getinterval ()
Refresh (), stop ()

Code Demonstration:

<! 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;
Width: 95%;
Height: 350px;
Font-size: 12px;
Overflow: auto;
}
. Xframesetting {
Display: none;
}
</Style>
<SCRIPT type = "text/JavaScript">
// <! [CDATA [
//********************/
// Xframe of X Series
// Author: Hutia
// It cannot be reproduced or used for commercial purposes without consent
//********************/
/*
Note:
X series is a series of js code developed by Hutia. With the corresponding CSS, you can quickly customize tags.
Currently, xframe supports ie5.5 and ff1.5 browsers (incomplete, garbled characters may occur)
The xframe label is
<Div class = "xframe">
<SPAN class = "xframesetting"> src = "" interval = "2000" </span>
Loading...
</Div>

Supported attributes:
None
Supported methods:
Setsrc (string URL), getsrc (), setinterval (INT interval), getinterval ()
Refresh (), stop ()
*/
// ** Load CSS *****
VaR xframecssfilepath = "Sp \/CSS \/xframe.css ";
// Document. Write ("<style> @ import URL (" + xframecssfilepath + "); </style> ");
// ** Check the browser type *****
VaR browsername = "";
Switch (navigator. appname. tolowercase ()){
Case "Netscape ":
Browsername = "ns ";
Break;
Case "Microsoft Internet Explorer ":
Default:
Browsername = "ie ";
Break;
}
// ** Set the initialization event ******
Switch (browsername ){
Case "ns ":
Window. addeventlistener ("LOAD", _ xframe_init, false );
Break;
Case "ie ":
Default:
Window. attachevent ("onLoad", _ xframe_init );
}
// ** Check whether the required VBScript function exists. If it does not exist, write ****
Try {
If (typeof (RSB) = "undefined") {initvbs ();};
} Catch (e) {initvbs ();}
// ** Global variables **
// Glbencode stores the conversion of ASCII to unicode characters, which improves the decoding efficiency during repeated decoding.
Glbencode = new array ();
// ** Set global timer ******
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 ();
Export xseriatimer__.handle=setinterval(__xseriatimer.exe .exe C ,__ xseriatimer _. interval );
},
Stop: function (){
Clearinterval (_ xseriatimer _. Handle );
}
};
_ Xseriatimer _. Start ();
}
// ** Initialize the function ******
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]);
}
}
// ** Event Response Function Area ******
Function _ xframe_event_doinit (element ){
// Initialize the variable
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 );
}

// Setting method
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;

// Set the event
Element. Check = _ xframe_event_docheck;
Element. Error = _ xframe_event_doerror;

// Get settings
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) {// the HTTP server response value is 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;
}
// ** Method function area ******
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; // you cannot reference xframe In the event function.
This. _ refreshtimehandle =__ xseriatimer __. push ("check (); If (_ xseriatimer __. times % "+ this. _ interval + "= 0) Refresh ();", this );
}
Function _ xframe_method_stop (){
_ Xseriatimer _. Pop (this. _ refreshtimehandle );
This. _ refreshtimehandle = NULL;
}
// ** Common function area ***
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 );
}
// Re-Encoding
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 ("% "));
}
// ** Initialize the function **
Function initvbs (){
// Initialize two funtion of VBScript: RSB and 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 [
//********************/
// Xframe of X Series
// Author: Hutia
// It cannot be reproduced or used for commercial purposes without consent
//********************/
/*
Note:
X series is a series of js code developed by Hutia. With the corresponding CSS, you can quickly customize tags.
Currently, xframe supports ie5.5 and ff1.5 browsers (incomplete, garbled characters may occur)
The xframe label is
<Div class = "xframe">
<SPAN class = "xframesetting"> src = "" interval = "2000" </span>
Loading...
</Div>

Supported attributes:
None
Supported methods:
Setsrc (string URL), getsrc (), setinterval (INT interval), getinterval ()
Refresh (), stop ()
*/
// ** Load CSS *****
VaR xframecssfilepath = "Sp \/CSS \/xframe.css ";
Document. Write ("<style> @ import URL (" + xframecssfilepath + "); </style> ");
// ** Check the browser type *****
VaR browsername = "";
Switch (navigator. appname. tolowercase ()){
Case "Netscape ":
Browsername = "ns ";
Break;
Case "Microsoft Internet Explorer ":
Default:
Browsername = "ie ";
Break;
}
// ** Set the initialization event ******
Switch (browsername ){
Case "ns ":
Window. addeventlistener ("LOAD", _ xframe_init, false );
Break;
Case "ie ":
Default:
Window. attachevent ("onLoad", _ xframe_init );
}
// ** Check whether the required VBScript function exists. If it does not exist, write ****
Try {
If (typeof (RSB) = "undefined") {initvbs ();};
} Catch (e) {initvbs ();}
// ** Global variables **
// Glbencode stores the conversion of ASCII to unicode characters, which improves the decoding efficiency during repeated decoding.
Glbencode = new array ();
// ** Set global timer ******
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 ();
Export xseriatimer__.handle=setinterval(__xseriatimer.exe .exe C ,__ xseriatimer _. interval );
},
Stop: function (){
Clearinterval (_ xseriatimer _. Handle );
}
};
_ Xseriatimer _. Start ();
}
// ** Initialize the function ******
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]);
}
}
// ** Event Response Function Area ******
Function _ xframe_event_doinit (element ){
// Initialize the variable
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 );
}

// Setting method
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;

// Set the event
Element. Check = _ xframe_event_docheck;
Element. Error = _ xframe_event_doerror;

// Get settings
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) {// the HTTP server response value is 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;
}
// ** Method function area ******
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; // you cannot reference xframe In the event function.
This. _ refreshtimehandle =__ xseriatimer __. push ("check (); If (_ xseriatimer __. times % "+ this. _ interval + "= 0) Refresh ();", this );
}
Function _ xframe_method_stop (){
_ Xseriatimer _. Pop (this. _ refreshtimehandle );
This. _ refreshtimehandle = NULL;
}
// ** Common function area ***
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 );
}
// Re-Encoding
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 ("% "));
}
// ** Initialize the function **
Function initvbs (){
// Initialize two funtion of VBScript: RSB and 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;
Width: 95%;
Height: 350px;
Font-size: 12px;
Overflow: auto;
}
. Xframesetting {
Display: none;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.