主要函數:
[復制此代碼]CODE:
<!--
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'><img src='http://www.pushad.com/Info/images/loading.gif' /> 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 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";
}
}
}
}
//-->
調用方法:
[復制此代碼]CODE:<li style="cursor:pointer" id="tab3" >最新折扣信息</li>