返回织梦建站服务网首页 业界新闻 教程文档 资源下载 酷站鉴赏 免费服务 站长工具
织梦建站工作室
织梦建站论坛
载入中…
专题栏目
最新热门
>>更多热门...  
最新推荐
>>更多推荐...  
  您现在的位置: 织梦建站服务网 >> 建站教程 >> 网络编程 >> 其他相关 >> 教程正文
Ajax标签导航效果            
HITS: TIME:2007-3-30 12:43:03 AUTHOR:yaohaixi… URL:蓝色理想
CONTENT INTRODUCE :
放大文字  缩小文字  发表评论  加入站内收藏夹  告诉好友  打印模式  关闭窗口 

效果演示

function.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;

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 = "服务器繁忙,请稍后重新连接!";}
       }
   }
}

function getnews(tagid,x){
   var url = tagid+'_'+x+'.htm';
   requestType = tagid;
   CreateXMLHttpRequest();  
  
   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";
            }            
        }        
   }
}
//-->

style.css

body{ margin: 0;padding: 0;background: #FFF;color: #000;font: normal 12px 宋体,arial,sans-serif;text-align: left;}
div,form,ul,ol,li,span,p {border: 0;margin: 0;padding: 0;}

/*链接样式*/
a:link{color: #000;text-decoration: none;}
a:visited{color: #000;text-decoration: none;}
a:hover{color: #16387C;text-decoration: underline;}

/*清除float*/
.clear{ clear: both; font-size:1px; visibility: hidden; }

/*空格*/
.blank2{font-size: 1px;height: 2px;margin: 0 auto;width: 962px;}
.blank5{font-size: 1px;height: 5px;margin: 0 auto;width: 950px;}
.sblank2{font-size: 1px;height: 2px;margin: 0 auto;width: 100px;}
.sblank3{font-size: 1px;height: 3px;margin: 0 auto;width: 100px;}
.sblank5{font-size: 1px;height: 5px;margin: 0 auto;width: 400px;}
.sblank7{font-size: 1px;height: 7px;margin: 0 auto;width: 400px;}

/*边距*/
.margin-right{margin-right: 6px;}
.margin-right-left{margin-right: 3px; margin-left:3px;}

/*字体颜色*/
.fcborange{color: #F0741A;font: bold 12px arial,sans-serif;}
.fcred{color:#FF0000;}
.fcwhite{color:#FFF;font:normal 13px 宋体,arial,sans-serif;letter-spacing:1px;}

/*新闻标签导航*/
.news_tabsnav{
    background: url(../images/tab_bg.gif) #FFF left top repeat-x;
    border: solid #B0BEC7;
    border-width: 0 1px 0 1px;
    height: 22px;
    margin: 0 auto;
    padding: 0;
    width: 506px;
}

.news_tabsnav .tabsmenu{
    height: 22px;
}

.news_tabsnav .tab_sline {
    padding-top: 3px;
    width: 2px;
}

.news_tabsnav li {
    color: #18397C;
    display: inline;
    float: left;
    font: normal 12px 宋体,arial,sans-serif;
    letter-spacing: 1px;
    list-style-type: none;
    margin: 0;
    padding-top: 4px;
    text-align: center;
    width: 120px;
}

/*导航菜单点击后的样式*/
.news_tabsnav .tabactive1{
    background: url(../images/tab_active1.gif);
    color: #F26400;
    font: bold 12px 宋体,arial,sans-serif;
    height: 18px;
    letter-spacing: 1px;
    padding-top: 4px;
    text-align: center;
    width: 120px;
}

.news_tabsnav .tabactive3{
    background: url(../images/tab_active2.gif);
    color: #F26400;
    font: bold 12px 宋体,arial,sans-serif;
    height: 18px;
    letter-spacing: 1px;
    padding-top: 4px;
    text-align: center;
    width: 120px;
}

.news_tabsnav .tabactive5{
    background: url(../images/tab_active2.gif);
    color: #F26400;
    font: bold 12px 宋体,arial,sans-serif;
    height: 18px;
    letter-spacing: 1px;
    padding-top: 4px;
    text-align: center;
    width: 120px;
}

.news_tabsnav .tabactive7{
    background: url(../images/tab_active2.gif);
    color: #F26400;
    font: bold 12px 宋体,arial,sans-serif;
    height: 18px;
    letter-spacing: 1px;
    padding-top: 4px

[1] [2] [3] 下一页

教程录入:jerome    责任编辑:jerome 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口

    相关教程
    仿6room网站图片链接效果
    打破玻璃的动画效果
    [Flash] 图片轮换效果
    flash8 绘制至尊土豆
    flash电子书鼠标拖拽翻页效果原理
    Flash & Ajax 操作 XML
    [AS]超真实火焰效果
    理性思考Flash与Ajax相关问题
    FLASH 实现动态模糊效果
    flash缓动效果
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    湘ICP备05010790号 {$Wap}
    关于我们 | 版本历史 | 联系方法 | 隐私条例 | 链接我们 | 广告服务 | 常见问题 | 友情链接 | 网站公告 | 设为首页 | 收藏本站
    Copyright © 2001-2006 17zm.NET All Rights Reserved.  织梦建站工作室[织梦建站工作室]™荣誉出品. Since 2001