163 AJAX Tab_ajax Related

Source: Internet
Author: User

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

Related Article

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.