zoukankan      html  css  js  c++  java
  • JavaScript+WebService分页


    function StringBuilder(value) 
    this.strings = new Array(""); 
    this.append(value); 
    // Appends the given value to the end of this instance. 
    StringBuilder.prototype.append = function (value) 
    if (value) 
    this.strings.push(value); 
    // Clears the string buffer 
    StringBuilder.prototype.clear = function () 
    this.strings.length = 1; 
    // Converts this instance to a String. 
    StringBuilder.prototype.toString = function () 
    return this.strings.join(""); 

        <script type="text/javascript">
            Date.prototype.format = function(fmt) {
                var o = {
                    "M+": this.getMonth() + 1,
           
                    "d+": this.getDate(),
                
                    "h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12,
                  
                    "H+": this.getHours(),
                
                    "m+": this.getMinutes(),
                
                    "s+": this.getSeconds(),
               
                    "q+": Math.floor((this.getMonth() + 3) / 3),
               
                    "S": this.getMilliseconds()
                };
                var week = {
                    "0": "\u65e5",
                    "1": "\u4e00",
                    "2": "\u4e8c",
                    "3": "\u4e09",
                    "4": "\u56db",
                    "5": "\u4e94",
                    "6": "\u516d"
                };
                if (/(y+)/.test(fmt)) {
                    fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
                }
                if (/(E+)/.test(fmt)) {
                    fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "\u661f\u671f" : "\u5468") : "") + week[this.getDay() + ""]);
                }
                for (var k in o) {
                    if (new RegExp("(" + k + ")").test(fmt)) {
                        fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
                    }
                }
                return fmt;
            }
           

            var currentPage = 1;
            var pageCount;
        function pageLoad()
        {
            CallWebMethod(currentPage);

        }
        function CallWebMethod(currentPage) {
            DolphinSites.WebService.GetAppInfo(currentPage,FillList);
        }
        function FillList(result) {
            var sBuilder = new StringBuilder();
            sBuilder.append('<table cellspacing="0" style=" 100%; margin-left:4px">');
            for (var i = 0; i < result.length; i++) 
            {
                sBuilder.append('<tr><td rowspan="2" style="padding-top:1px ; padding-bottom:1px;border-bottom:1px solid #cecece;text-align: left;   56px">');
                sBuilder.append('<a title="Google" href="AppsDetail.aspx?id=' + result[i].Id + '">');
                sBuilder.append('<img alt="Google" width="50px" src=' + result[i].Screenshot + ' /></a></td>');
                sBuilder.append(' <td style=" color:#cecece; font-size:13px; font-weight:700; padding-left:11px;">');
                sBuilder.append('<a href="AppsDetail.aspx?id=' + result[i].Id + '"');
                sBuilder.append(' style="text-decoration:none;color:#777777"><div style=" 120px; height:20px;overflow:hidden">');
                sBuilder.append(result[i].AppName);
                sBuilder.append('</div></a><div style="font-size:8px">Release date:' + result[i].CreateTime.format("dd/MM/yyyy") + '</div></td><td align="right" style=" color:#F58600; font-size:10px;">');
                sBuilder.append(result[i].Price);
                sBuilder.append(' </td></tr><tr>');
                sBuilder.append(' <td colspan="2" style="text-align: left; font-size:12px;border-bottom:1px solid #cecece">');
                sBuilder.append('<div style="display:block; margin-top:0px;  margin-bottom:2px; line-height :12px; overflow:hidden;  height :60px; "><a href="AppsDetail.aspx?id=' + result[i].Id + '" style=" text-decoration:none; font-size:12px;" >');
                sBuilder.append('<a href="AppsDetail.aspx?Id=' + result[i].Id + '" style="text-decoration:none ">');
                sBuilder.append(result[i].Introduction);
                sBuilder.append('</a></div></td><td style="border-bottom:1px solid #cecece"></td>');
                sBuilder.append('<td style="border-bottom:1px solid #cecece; color:#72B311; text-decoration:none; 20%; text-align:center;"><a href="AppsDetail.aspx?id=' + result[i].Id + '">');
                sBuilder.append('<img src="Images/Detail/imgNext.png" alt="MoreInfo" width="12" height="17" /></a></td></tr>');

            }
            sBuilder.append('</table>');
            document.getElementById("sPage").innerHTML = sBuilder;
            //GetPageCount();
        }
       
        function GetPageCount() {

           
         
            if (currentPage == 1) {

                document.getElementById('ImgPre').disabled = "disabled";
                document.getElementById('ImgPre').onclick = "";
            }
            if (currentPage == pageCount) {

                document.getElementById('ImgNext').disabled = "disabled";
                document.getElementById('ImgNext').onclick = "";

            }
        }
       
        function PageNation(page) {
            switch (page) {

                case "pre":
                    currentPage -= 1;
                    if (currentPage == 0) {
                        currentPage = 1;
                    }
                    CallWebMethod(currentPage) ;
                    break;
                case "next":
                    currentPage += 1;
                    if (currentPage > pageCount) {
                        currentPage = pageCount;
                    }
                    CallWebMethod(currentPage);
                    break;

            }
        }
        </script>
        
  • 相关阅读:
    python爬虫(十六) -IndexError: list index out of range
    python爬虫(十五) 豆瓣电影爬虫
    python爬虫(十四)
    python爬虫(十三) lxml模块
    python爬虫(十二) XPath语法
    python爬虫(十一) session
    python爬虫(十) requests使用代理ip
    python爬虫(九) requests库之post请求
    python爬虫(八) requests库之 get请求
    PXE+kickstart网络安装CentOS7.4系统及过程中各种报错
  • 原文地址:https://www.cnblogs.com/hubcarl/p/1702907.html
Copyright © 2011-2022 走看看