Main functions:
Copy codeThe Code is as follows: <! --
Function getObject (objectId ){
If (document. getElementById & document. getElementById (objectId )){
// W3C DOM
Return document. getElementById (objectId );
}
Else if (document. all & document. all (objectId )){
// MSIE 4 DOM
Return document. all (objectId );
}
Else if (document. layers & document. layers [objectId]) {
// NN 4 DOM.. note: this won't find nested layers
Return document. layers [objectId];
}
Else {
Return false;
}
}
Var responsecont;
Var xmlHttp;
Var requestType;
Var newsstring;
Function CreateXMLHttpRequest (){
// Initialize Mozilla XMLHttpRequest object
If (window. XMLHttpRequest ){
XmlHttp = new XMLHttpRequest ();
}
// Initialize for IE/Windows ActiveX version
Else if (window. ActiveXObject ){
Try {
XmlHttp = new ActiveXObject ("Msxml2.XMLHTTP. 3.0 ");
}
Catch (e ){
Try {
XmlHttp = new ActiveXObject ("Microsoft. XMLHTTP ");
}
Catch (e) {newsstring = "<div class = 'loading'> loading rquest content fail, Please try it again latter... </div> ";}
}
}
}
Function getnews (tagid, x ){
Var url = tagid='_'{x}'.htm ';
Var loadstatustext = "<div class = 'loading'> loading request content, please wait... </div> ";
RequestType = tagid;
CreateXMLHttpRequest ();
GetObject (requestType + '_ cnt'). innerHTML = loadstatustext;
XmlHttp. onreadystatechange = processRequestChange;
XmlHttp. open ("GET", url, true );
XmlHttp. setRequestHeader ("If-Modified-Since", "0 ");
XmlHttp. send (null );
}
Function processRequestChange (){
// Only if xmlHttp shows "complete"
If (xmlHttp. readyState = 4 ){
// Only the http 200 to process
If (window. location. href. indexOf ("http") =-1 | xmlHttp. status = 200 ){
Newsstring = xmlHttp. responseText;
// Inject centent to tab-pane
Shownews (requestType, newsstring );
}
}
}
Function shownews (requestType, newsstring ){
// <! [CDATA [
Responsecont = getObject (requestType + '_ cnt ');
Responsecont. innerHTML = newsstring;
//]>
}
Function TabNews (tagid, x ){
For (var I = 1; I <= 7; I + = 2 ){
If (I = x ){
GetObject (tagid + I). className = "tabactive" + I;
If (I! = 1 ){
GetObject (tagid + (I-1). style. display = "none ";
If (I! = 7 ){
GetObject (tagid + (I + 1). style. display = "none ";
}
}
If (I = 1 ){
GetObject (tagid + "2"). style. display = "none ";
}
Try {
Getnews (tagid, I );
}
Catch (e ){
Alert (e );
}
}
Else
{
GetObject (tagid + I). className = "";
If (I! = 7 ){
GetObject (tagid + (I + 1). style. display = "block ";
}
}
}
}
// -->
Call method:Copy codeThe Code is as follows: <li style = "cursor: pointer" id = "tab3" onclick = "TabNews ('tab', 3)"> latest discount Information </li>