ajax實(shí)現(xiàn)標(biāo)簽導(dǎo)航
<!--
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='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";
}
}
}
}
//-->
調(diào)用方法:
相關(guān)文章
Ajax標(biāo)簽導(dǎo)航效果(仿網(wǎng)易首頁)
Ajax標(biāo)簽導(dǎo)航效果(仿網(wǎng)易首頁)...2006-10-10ajax實(shí)現(xiàn)select三級(jí)聯(lián)動(dòng)效果
這篇文章主要為大家詳細(xì)介紹了ajax動(dòng)態(tài)實(shí)現(xiàn)select三級(jí)聯(lián)動(dòng),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-01-01Jquery Ajax請(qǐng)求方法小結(jié)(值得收藏)
本文給大家介紹jquery ajax請(qǐng)求方法小結(jié),jquery作為一個(gè)輕量級(jí)的js框架,能快速的開發(fā)js應(yīng)用,并且在一定程度上改變了我們寫js代碼的習(xí)慣,對(duì)jquery ajax請(qǐng)求感興趣的朋友參考下2015-11-11jquery1.8版本使用ajax實(shí)現(xiàn)微信調(diào)用出現(xiàn)的問題分析及解決辦法
這篇文章主要介紹了jquery1.8版本使用ajax實(shí)現(xiàn)微信調(diào)用出現(xiàn)的問題分析及解決辦法的相關(guān)資料,需要的朋友可以參考下2015-11-11一個(gè)AJAX自動(dòng)完成功能的js封裝源碼[支持中文]
一個(gè)AJAX自動(dòng)完成功能的js封裝源碼[支持中文]...2007-02-02ajax+asp無限級(jí)分類樹型結(jié)構(gòu)的代碼
ajax+asp無限級(jí)分類樹型結(jié)構(gòu)的代碼...2007-10-10jquery通過AJAX從后臺(tái)獲取信息并顯示在表格上的實(shí)現(xiàn)類
今天小編抽給時(shí)間把jquery通過AJAX從后臺(tái)獲取信息并顯示在表格上的實(shí)現(xiàn)類,單獨(dú)寫出來,這樣程序員,不需要每次寫代碼了,可以節(jié)省大量的時(shí)間,感興趣的朋友一起來看看吧2015-09-09Jquery版本導(dǎo)致Ajax不執(zhí)行success回調(diào)函數(shù)
這篇文章主要介紹了Jquery Ajax不執(zhí)行success回調(diào)函數(shù)的原因及解決方法2014-04-04