Copy Code code as follows:
163 AJAX Tab
Update 2006.10.18
Increase mouse latency sensing characteristics.
Update 2006.10.8
A label href attribute will retain the original HTML functionality. The Urn property is added to the Ajax Load path.
Update 2006.10.11
Fixed IE5.0 undefined undefined error, increasing script error shielding
var Browser = new Object ();
Browser.ismozilla = (typeof document.implementation!= ' undefined ') && (typeof Document.implementation.createDocument!= ' undefined ') && (typeof htmldocument!= ' undefined ');
Browser.isie = window. ActiveXObject? True:false;
Browser.isfirefox = (Navigator.userAgent.toLowerCase (). IndexOf ("Firefox")!=-1);
Browser.isopera = (Navigator.userAgent.toLowerCase (). IndexOf ("opera")!=-1);
if (Browser.isfirefox) {//entend Event Mod for FireFox
Extendeventobject ();
}
function Extendeventobject () {
event.prototype.__definegetter__ ("Srcelement", function () {
var node = This.target;
while (Node.nodetype!= 1) node = Node.parentnode;
return node;
});
event.prototype.__definegetter__ ("Fromelement", function () {
var node;
if (This.type = = "MouseOver")
node = This.relatedtarget;
else if (This.type = "Mouseout")
node = This.target;
if (!node) return;
while (Node.nodetype!= 1) node = Node.parentnode;
return node;
});
event.prototype.__definegetter__ ("Toelement", function () {
var node;
if (This.type = = "Mouseout")
node = This.relatedtarget;
else if (This.type = "MouseOver")
node = This.target;
if (!node) return;
while (Node.nodetype!= 1) node = Node.parentnode;
return node;
});
}
function IsChild (cnode,pnode) {
while (Cnode!=null) {
Cnode=cnode.parentnode;
if (Cnode==pnode) return true;
}
return false;
}
var ajccache=new Object ();
var waitinterval;
var tempref;
var mousedelaytime=150;//mouse sensor delay 300 milliseconds
function Gettbprefixname (Str,sta) {
if (Str.indexof ("active")!=-1 | | str.indexof ("normal")!=-1) Str=str.substr (6);
else if (Str.indexof ("over")!=-1) Str=str.substr (4);
else str= "";
return sta+str;
}
function Startajaxtabs () {
for (Var i=0;i<arguments.length;i++)
{
var Ulobj=document.getelementbyid (Arguments[i]);
Ulist=ulobj.getelementsbytagname ("Li");
for (Var j=0;j<ulist.length;j++)
{
var thelist=ulist[j];
if (thelist.parentnode.parentnode!=ulobj) continue;//only the first layer of Li effective fixed 2006.9.29
var ulistlink=thelist.getelementsbytagname ("a") [0];
var ulistlinkurl=ulistlink.getattribute ("urn");
var ulistlinktarget=ulistlink.getattribute ("rel");
Thelist.setactive=function (bactive) {
if (bactive) {
This.status= "Active";
This.classname=gettbprefixname (This.classname, "active");
}else{
This.status= "Normal";
This.classname=gettbprefixname (This.classname, "normal");
}
}
Thelist. Loadtab=function () {
This.setactive (TRUE);
This.parentNode.parentNode.activetab.setActive (FALSE);
This.parentnode.parentnode.activetab=this;
var ulistlink=this.getelementsbytagname ("a") [0];
Loadajaxtab (Ulistlink.getattribute ("urn"), Ulistlink.getattribute ("rel"));
}
Thelist.onmouseover=function (aevent) {
var myevent = window.event? Window.event:aEvent;
var fm=myevent.fromelement;
if (IsChild (fm,this) | | | fm==this) return;//Filter child element event
if (this.status== "active") return;
Tempref=this;
Cleartimeout (Waitinterval);
Waitinterval=window.settimeout ("Tempref.") Loadtab (); ", mousedelaytime);
}
Thelist.onmouseout=function (aevent) {
var myevent = window.event? Window.event:aEvent;
var em=myevent.toelement;
if (IsChild (em,this) | | | em==this) return; Filter child element Event
if (this.status== "active") return;
Cleartimeout (Waitinterval);
}
if (Ulistlinkurl.indexof ("#default")!=-1) {
Thelist.setactive (TRUE);
Ulobj.activetab=thelist;
Ajccache[ulistlinkurl]=getelement (ulistlinktarget). InnerHTML;
}else{
Thelist.setactive (FALSE);
}
}
if (ulobj.activetab==null) ulobj.activetab=ulist[0];
}
}
function Getxmlhttp ()
{
var http_request;
if (window. XMLHttpRequest) {
Http_request = new XMLHttpRequest ();
if (Http_request.overridemimetype) {
Http_request.overridemimetype ("Text/xml");
}
}
else if (window. ActiveXObject) {
try {
Http_request = new ActiveXObject ("Msxml2.xmlhttp");
catch (e) {
try {
Http_request = new ActiveXObject ("Microsoft.XMLHTTP");
catch (e) {}
}
}
if (!http_request) {
Window.alert ("can" T create XMLHttpRequest object);
return null;
}
return http_request;
}
function Loadajaxtab (Url,contentid) {
var ocontent=getelement (ContentID);
if (ajccache[url]==null) {
var xhttp=getxmlhttp ();
Xhttp.onreadystatechange=function () {
if (xhttp.readystate = 4 && (xhttp.status==200 | | window.location.href.indexOf ("http") ==-1))
{
Ocontent.innerhtml=xhttp.responsetext;
ajccache[url]=ocontent.innerhtml;
}
}
Xhttp.open ("Get", url,true);
Xhttp.send (NULL);
}else{
Ocontent.innerhtml=ajccache[url];
}
}
Window.onerror=function () {return true}
Concrete use method, see www.163.com use of