ajax.js里面有内容显示效果根据ID

2016-02-19 13:00 53 1 收藏

下面请跟着图老师小编一起来了解下ajax.js里面有内容显示效果根据ID,精心挑选的内容希望大家喜欢,不要忘记点个赞哦!

【 tulaoshi.com - Web开发 】

ajax.js里面有内容显示效果,根据ID
代码如下:

    var http_request = false;
    var success=false;
    var ShowAllListFlag=1;
    var DisplayArticle=true;
    function makeRequest(url,cateID) {

        http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        http_request.onreadystatechange = alertContents;
        http_request.open('GET', url, false);
        http_request.send(null);
        if (success==true)
        {
            try {
                   cateID.innerHTML=http_request.responseText;
                } catch (e) {}

            success==false;
        }

    }

    function alertContents() {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                success=true;
            } else {
                alert('There was a problem with the request.');
            }
        }

    }

    function setCatlog(ID,Order,LeftNumber) {

        var cateID=document.getElementById('Cate'+ID);
        setdisplay(cateID);
        if (cateID.style.display=="")
        {
        var url2="INCLUDE/GetSiteListFunction.asp?ID="+ID+"&Order="+Order+"&LeftNumber="+LeftNumber+"&r="+Math.random();
        makeRequest(url2,cateID);
        }
        else
        {
        var url2="INCLUDE/GetSiteListFunction.asp?ID="+ID+"&RemoveID=1&r="+Math.random();
        makeRequest(url2,cateID);
        }
    }

    function setArticleList(EncodeURL,ArticleID) {

        if (DisplayArticle==true)
        {
            try {  var objArticleIDtop = document.getElementById('top'+ArticleID);
               var objArticleIDbottom = document.getElementById('bottom'+ArticleID);
               if (objArticleIDtop)
                  {
                    if  (objArticleIDtop.style.display=="none")
                    {

                    objArticleIDtop.style.display="";
                    }
                    else
                    {

                    objArticleIDtop.style.display="none";
                    }
                  } 
                  if (objArticleIDbottom)
                  {
                    if  (objArticleIDbottom.style.display=="none")
                    {
                    var url2="INCLUDE/GetArticleFunction.asp?LinkStr="+EncodeURL+"&r="+Math.random();
                    makeRequest(url2,objArticleIDbottom);
                    objArticleIDbottom.style.display="";
                    }
                    else
                    {

                    objArticleIDbottom.style.display="none";
                    }
                  } 

             } catch (e) {alert(e.description);}
        }
        else
        {
        }

    }


    function DisplayContent(ArticleID) {

        if (DisplayArticle==true)
        {
            try {  var objArticleIDtop = document.getElementById('top'+ArticleID);
               var objArticleIDbottom = document.getElementById('bottom'+ArticleID);
               if (objArticleIDtop)
                  {
                    if  (objArticleIDtop.style.display=="none")
                    {

                    objArticleIDtop.style.display="";
                    }
                    else
                    {

                    objArticleIDtop.style.display="none";
                    }
                  } 
                  if (objArticleIDbottom)
                  {
                    if  (objArticleIDbottom.style.display=="none")
                    {

                    objArticleIDbottom.style.display="";
                    }
                    else
                    {

                    objArticleIDbottom.style.display="none";
                    }
                  } 

             } catch (e) {alert(e.description);}
        }
        else
        {
        }

    }

    function setdisplay(cateID) {
        if  (cateID.style.display=="none")
        {
        cateID.style.display="";
        cateID.innerHTML="Loading..."
        }
        else
        {
        cateID.style.display="none";  
        }
    }

    function setdisplay2(cateID) {

        if (ShowAllListFlag==1)
        {
          cateID.style.display="";
          cateID.innerHTML="Loading..."
        }
        else
        {
          cateID.style.display="none";
        }
    }

    function ShowAllList(Order,LeftNumber,TagName)    {
        var obj = document.getElementsByTagName(TagName)

        for (a=0;aobj.length;a++)
        {
            if (obj[a].className=="SiteList")
            {
                obj2=obj[a].id;
                var ID=obj2.replace("Cate","");
                var cateID=document.getElementById(obj2);
                setdisplay2(cateID);
                if (cateID.style.display=="")
                {
                var url2="INCLUDE/GetSiteListFunction.asp?ID="+ID+"&Order="+Order+"&LeftNumber="+LeftNumber+"&r="+Math.random();
                makeRequest(url2,cateID);
                }
                else
                {
                var url2="INCLUDE/GetSiteListFunction.asp?ID="+ID+"&RemoveID=1&r="+Math.random();
                makeRequest(url2,cateID);
                }

            }

        }

        if (ShowAllListFlag==1)
        {
            ShowAllListFlag=2;
        }
        else
        {
            ShowAllListFlag=1;
        }

    }

    function ExpandListBySession(Str,Order,LeftNumber) {
        try {
                var ExpandList=Str.split("|");

                for (b=0;bExpandList.length-1;b++)
                {
                    setCatlog(ExpandList[b],Order,LeftNumber)        
                }
             } catch (e) {}

    }

来源:http://www.tulaoshi.com/n/20160219/1602723.html

延伸阅读
标签: 健康生活
桑葚里面有虫子吗 桑葚是一种营养极其丰富的野生果实,我们平时经常会食用它,尤其是在夏天,桑葚酸甜可口的味道可以让炎热的气温变得凉爽。我们平时在食用桑葚时,将桑葚用清水清洗即可食用。有的人说,桑葚里面有虫子,这样的清洗方式并没有将它清洗干净。那么,到底桑葚里面有没有虫子呢?下面,我们一起来看看下面的内容。 桑葚一般没有...
空调病经验分享 图钉问: 反正感觉生活已经离不开空调了,特别是冬天和夏天,整天整天的待在空调里面,这样对身体有什么坏处呢? 图老师答: 空调只能调节室内的文帝和湿度,不能使室内外空气流通。关闭门窗,开启空调,室内污染物的浓度就增高了,会对人体造成危害。空气不流通,又会给病菌提供繁殖的环境,人体也容易染病。 另...
经验分享 图钉问: 这次买的爽肤水里面有很多泡沫,感觉之前买的没什么泡沫啊?是不是这次买的爽肤水质量不太好啊? 图老师答: 1、如果泡泡细腻丰富,有厚厚的一层,而且经久不消,那就是好的水; 2、如果泡泡很少,说明营养成分少; 3、如果泡泡多但是大,说明含有水杨酸较多; 4、如果泡泡本来多后来很快就消了,那说明其中...
标签: Web开发
SCRIPT language=JavaScript1.2 iens6=document.all||document.getElementById ns4=document.layers //specify speed of scroll (greater=faster) var speed=10 if (iens6){ document.write('div id="container" style="position:relative;width:600;height:430;border:0px solid&nb...

经验教程

705

收藏

60
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部