AJAX implements tag navigation _ajax related

Source: Internet
Author: User
main functions:
Copy Code code as follows:

<!--
function GetObject (objectId) {
if (document.getElementById && document.getElementById (objectId)) {
The Consortium 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 ' > The 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 HTTP 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 Code code as follows:
<li style= "Cursor:pointer" id= "Tab3" onclick= "tabnews" (' tab ', 3) "> Latest discount information </li>

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.