DDR爱好者之家 Design By 杰米
根据yaohaixiao的Ajax标签导航效果:http://www.blueidea.com/tech/web/2006/4144.asp改进。
效果:
http://www.lorlo.com/tab.html
主要是改了JS:
复制代码 代码如下:
<!--
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;
var ajccache=new Object();//缓存已访问的数据页面
var url;
var MouseDelayTime=150;//鼠标感应延迟
var waitInterval;
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){
url = "tab/"+tagid+'_'+x+'.html';
// var loadstatustext="<div class='loading'><img src='images/loading.gif' /> Loading request content, please wait...</div>";
requestType = tagid;
if(ajccache[url]==null){
CreateXMLHttpRequest();
// getObject(requestType+'_cnt').innerHTML = loadstatustext;
xmlHttp.onreadystatechange = processRequestChange;
xmlHttp.open("GET", url, true);
xmlHttp.setRequestHeader("If-Modified-Since","0");
xmlHttp.send(null);
}
else
{ shownews(requestType,ajccache[url]); }
}
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);
ajccache[url]=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";
}
}
}
}
var idn;
function aet(objid,tagid,etp){ //为LI加上事件 objid:容器ID tagid:组别 etp:触发类型 0-onmouseover 1-onclick
var iif=0;
var lis=objid.getElementsByTagName('li');
requestType=tagid;
url = "tab/"+requestType+"_1.html";
ajccache[url]=getObject(requestType+'_cnt').innerHTML;
for(var iy=0;iy<lis.length;iy++){
if(iif==0){
iif=1;
with(lis[iy]){
if(etp==0){
lis[iy].onmouseover=function(){
if(this.status=="active") return;
requestType=attributes.getNamedItem('id').value.substring(0, attributes.getNamedItem('id').value.length-1);
idn=parseInt(attributes.getNamedItem('id').value.substring(attributes.getNamedItem('id').value.length-1, attributes.getNamedItem('id').value.length));
clearTimeout(waitInterval);
waitInterval=window.setTimeout("TabNews(requestType,idn);",MouseDelayTime);
}
lis[iy].onmouseout=function(){if(this.status=="active") return;clearTimeout(waitInterval);}
}
if(etp==1){
lis[iy].onmouseover=function(){}
lis[iy].onclick=function(){
if(this.status=="active") return;
requestType=attributes.getNamedItem('id').value.substring(0, attributes.getNamedItem('id').value.length-1);
idn=parseInt(attributes.getNamedItem('id').value.substring(attributes.getNamedItem('id').value.length-1, attributes.getNamedItem('id').value.length));
var loadstatustext="<div class='loading'><img src='images/loading.gif' /> Loading request content, please wait...</div>";
getObject(requestType+'_cnt').innerHTML = loadstatustext;
TabNews(requestType,idn);
}}}}
else{iif=0;}
}
}
function ata(objid){ //一个无关的函数,为解决一个链接问题
var as=objid.getElementsByTagName('a');
for(var i=0;i<as.length;i++){
as[i].pathname="/showfile.html";
}
}
//-->
效果:
http://www.lorlo.com/tab.html
主要是改了JS:
复制代码 代码如下:
<!--
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;
var ajccache=new Object();//缓存已访问的数据页面
var url;
var MouseDelayTime=150;//鼠标感应延迟
var waitInterval;
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){
url = "tab/"+tagid+'_'+x+'.html';
// var loadstatustext="<div class='loading'><img src='images/loading.gif' /> Loading request content, please wait...</div>";
requestType = tagid;
if(ajccache[url]==null){
CreateXMLHttpRequest();
// getObject(requestType+'_cnt').innerHTML = loadstatustext;
xmlHttp.onreadystatechange = processRequestChange;
xmlHttp.open("GET", url, true);
xmlHttp.setRequestHeader("If-Modified-Since","0");
xmlHttp.send(null);
}
else
{ shownews(requestType,ajccache[url]); }
}
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);
ajccache[url]=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";
}
}
}
}
var idn;
function aet(objid,tagid,etp){ //为LI加上事件 objid:容器ID tagid:组别 etp:触发类型 0-onmouseover 1-onclick
var iif=0;
var lis=objid.getElementsByTagName('li');
requestType=tagid;
url = "tab/"+requestType+"_1.html";
ajccache[url]=getObject(requestType+'_cnt').innerHTML;
for(var iy=0;iy<lis.length;iy++){
if(iif==0){
iif=1;
with(lis[iy]){
if(etp==0){
lis[iy].onmouseover=function(){
if(this.status=="active") return;
requestType=attributes.getNamedItem('id').value.substring(0, attributes.getNamedItem('id').value.length-1);
idn=parseInt(attributes.getNamedItem('id').value.substring(attributes.getNamedItem('id').value.length-1, attributes.getNamedItem('id').value.length));
clearTimeout(waitInterval);
waitInterval=window.setTimeout("TabNews(requestType,idn);",MouseDelayTime);
}
lis[iy].onmouseout=function(){if(this.status=="active") return;clearTimeout(waitInterval);}
}
if(etp==1){
lis[iy].onmouseover=function(){}
lis[iy].onclick=function(){
if(this.status=="active") return;
requestType=attributes.getNamedItem('id').value.substring(0, attributes.getNamedItem('id').value.length-1);
idn=parseInt(attributes.getNamedItem('id').value.substring(attributes.getNamedItem('id').value.length-1, attributes.getNamedItem('id').value.length));
var loadstatustext="<div class='loading'><img src='images/loading.gif' /> Loading request content, please wait...</div>";
getObject(requestType+'_cnt').innerHTML = loadstatustext;
TabNews(requestType,idn);
}}}}
else{iif=0;}
}
}
function ata(objid){ //一个无关的函数,为解决一个链接问题
var as=objid.getElementsByTagName('a');
for(var i=0;i<as.length;i++){
as[i].pathname="/showfile.html";
}
}
//-->
DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米
暂无评论...
更新日志
2024年11月25日
2024年11月25日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]