乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      js生成html的方法

       二寶么么噠 2010-09-25

      生成HTML的方法

         生成HTML的方法實在是太多了,我來講講我現(xiàn)在要講的一個方法,想好一個從頭到尾的思路,拿一個新聞系統(tǒng)作為實例.powered by 25175.net

        假設(shè)的兩個表:news(ID,title,document,time),news_content(ID,news_id,username,document,time)
        文件名:我們將news的主鍵(ID)作為生成.HTML的文件名

      新建news_list.txt
      <a href="[$news->id].html" target="_blank">[$news->title]</a> [$news->time]<br/> 


      新建page.txt
      <div align="center"><a href="news_list_[$page->first].html">第一頁</a> <a href="news_list_[$page->prev].html">上一頁</a> <a href="news_list_[$page->next].html">下一頁</a> <a href="news_list_[$page->last].html">最后頁</a></div> 


      新建news_content_list.txt
      <tr>
      <td style="color:green;">[$news_content->username]</td>
      <td>[$news_content->document]</td>
      <td style="color:red;">[$news_content->time]</td>
      </tr> 


      新建news_document.txt
      <html>
      <head>
      </head>
      <body>
      ...
      <h1 style="color:red;" align="center"><b>[$news->title]</b></h1>
      <div align="center" style="color:green;">[$news->time]</div>
      <div>[$news->document]</div>
      ...
      相關(guān)評論:
      [$news_content]
      </body>
      </html> 


      分頁列表:

      <%
      function MPage(rs) {
           var pagesize=15;
           var totalpage=parseInt(con.Execute("select count(ID) from ("+rs.Source+")").Fields(0));
           totalpage=totalpage%pagesize==0?parseInt(totalpage/pagesize):parseInt(totalpage/pagesize)+1;
           var Template="";
           //讀文件Template.txt到Template變量中
           /*
           <html>
           <head>
           </head>
           <body>
           ...
           <div>[$news_list]</div>
           ...
           <div>[$page]</div>
           ...
           [$news_content]
           </body>
           </html>
           */
           var news_list="";
           //讀文件news_list.txt到news_list變量中
           /*
           <a href="[$news->id].html" target="_blank">[$news->title]</a> [$news->time]<br/>
           */
           var page="";
           //讀文件page.txt到news_list變量中
           /*
           <div align="center">
                 <a href="news_list_[$page->first].html">第一頁</a>
                 <a href="news_list_[$page->prev].html">上一頁</a>
                 <a href="news_list_[$page->next].html">下一頁</a>
                 <a href="news_list_[$page->last].html">最后頁</a>
           </div>
           */
           for(var i=0,pos=1;i<totalpage;i++,pos++) {
                 if(pos!=1) {rs.MoveFirst();rs.Move((pos-1)*pagesize);}
                 
                 var ostring=Template;
                 var otemp="";
                 
                 for(var j=0;j<pagesize;j++) {
                       var temp=news_list;
                       temp=temp.replace(/\[\$news->id\]/,String(rs.Fields("id")));
                       temp=temp.replace(/\[\$news->title\]/,String(rs.Fields("title")));
                       temp=temp.replace(/\[\$news->time\]/,String(rs.Fields("time")));
                       otemp+=temp;
                 }
                 
                 ostring=ostring.replace(/\[\$news_list\]/,String(otemp));

                 otemp=page;
                 otemp=otemp.replace(/[$page->first]/,String(1));
                 otemp=otemp.replace(/[$page->prev]/,String(pos-1));
                 otemp=otemp.replace(/[$page->next]/,String(pos+1));
                 otemp=otemp.replace(/[$page->last]/,String(totalpage));
                 
                 ostring=ostring.replace(/\[\$news_list\]/,String(otemp));
                 
                 var filename="news_list_"+pos+".html";
                 //將 ostring 的值寫到文件 filename 中
           }
           
      }
      %> 

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多