【文章內(nèi)容簡介】
(企業(yè)理念信息表)數(shù)據(jù)名數(shù)據(jù)類型說明id自動編號信息序號content備注信息內(nèi)容rongyu(榮譽資質(zhì)信息表)數(shù)據(jù)名數(shù)據(jù)類型說明id自動編號信息序號img文本圖片地址px數(shù)字排列位置shouye(首頁簡要介紹信息表)數(shù)據(jù)名數(shù)據(jù)類型說明id自動編號信息序號content備注信息內(nèi)容xinwen(新聞動態(tài)信息表)數(shù)據(jù)名數(shù)據(jù)類型說明id自動編號信息序號type數(shù)字所屬類別title文本新聞標題content備注新聞內(nèi)容time日期/時間發(fā)表時間xwlb(新聞類別信息表)數(shù)據(jù)名數(shù)據(jù)類型說明id自動編號信息序號title文本類別名稱zhici(董事長致辭信息表)數(shù)據(jù)名數(shù)據(jù)類型說明id自動編號信息序號content備注信息內(nèi)容zhuangbei(機械裝備信息表)數(shù)據(jù)名數(shù)據(jù)類型說明id自動編號信息序號img文本圖片地址px數(shù)字排列位置2.2.3 數(shù)據(jù)庫的連接ASP網(wǎng)頁與數(shù)據(jù)庫連接的代碼如下所示:%dim conn dim connstrconnstr=DBQ=+(data/)+。DefaultDir=。DRIVER={Microsoft Access Driver (*.mdb)}set conn=() connstr%第三章 網(wǎng)站前臺開發(fā)3.1 網(wǎng)站首頁的實現(xiàn)首頁最抓瀏覽者眼球的部分就是Flash動畫,占去首頁大部分版面。動畫包括企業(yè)Logo、動態(tài)下拉導航、企業(yè)標語、循環(huán)滾動的工程業(yè)績分類小圖,以及正中位置的高清晰大尺寸圖片秀。Flash開頭添加了loading功能,圖片和文字的運動也做了合理的安排和優(yōu)化,使之播放起來感覺很流暢。Flash動畫的下方拆分為四個版塊,左列是最新發(fā)布的前四條新聞,包括公司動態(tài)和行業(yè)新聞。第二列是企業(yè)的概要介紹,取前130個字加省略號,點擊可進入查看完整的企業(yè)介紹。第三列是四幅小圖,用來和上面的Flash相呼應,使頁面視覺取得平衡。最后一列是三個圖片鏈接,分別是設為首頁、加入收藏和網(wǎng)站地圖。首頁截圖如下:圖31 網(wǎng)站首頁3.1.1 左側(cè)最新新聞列表的實現(xiàn)取最新發(fā)布的前四條新聞,包括公司動態(tài)和行業(yè)新聞。相關源代碼如下:%set rs=() select top 4 id,title from [xinwen] order by id desc,conn,1,1do while not %table width=220 border=0 cellspacing=0 cellpadding=0trtd height=25 align=left valign=bottom style=BORDERBOTTOM: D1D0C9 1PX DASHEDamp。nbsp。img src=images/ width=11 height=11 /amp。nbsp。a href=?id=%=rs(id)% title=%=rs(title)%%=DoTrimProperly(rs(title),15,0,1,..)%/a/td/tr/table%loopset rs=nothing%3.1.2 首頁企業(yè)簡介的實現(xiàn)取最前面130個字符加省略號。相關源代碼如下:%set rs=() select * from [shouye] where id=1,conn,1,1if not then DoTrimProperly(rs(content),130,0,1,...)end ifset rs=nothing%3.2 走近博元的實現(xiàn)這是一個總的模塊,又分為如下三個子模塊:企業(yè)介紹、企業(yè)理念和董事長致辭,這三部分的結(jié)構(gòu)是相同的,都為圖片混排的形式,對應數(shù)據(jù)庫中的數(shù)據(jù)格式為備注類型。這三部分的相關代碼都很簡潔,只需從庫中讀取相應的那條紀錄,過濾掉../(調(diào)整圖片路徑)就行了。3.2.1 企業(yè)介紹的實現(xiàn)網(wǎng)頁截圖如下:圖32 企業(yè)介紹相關源代碼如下:%set rs=() select * from [jieshao] where id=1,conn,1,1if not then replace(rs(content),../uploadfile,uploadfile)end ifset rs=nothing%3.2.2 企業(yè)理念的實現(xiàn)結(jié)構(gòu)和企業(yè)介紹相同,相關源代碼如下:%set rs=() select * from [linian] where id=1,conn,1,1if not then replace(rs(content),../uploadfile,uploadfile)end ifset rs=nothing%3.2.3 董事長致辭的實現(xiàn)結(jié)構(gòu)和上面兩個模塊相同,相關源代碼如下:%set rs=() select * from [zhici] where id=1,conn,1,1if not then replace(rs(content),../uploadfile,uploadfile)end ifset rs=nothing%3.3 企業(yè)榮譽的實現(xiàn)這個模塊分為榮譽資質(zhì)和領導關懷兩個子模塊,都為圖片陳列的形式,稍有不同的是,領導關懷中增加了對每張圖片的簡要說明文字。圖片每行顯示3張,每頁顯示15張,剩下的被分到下一頁繼續(xù)顯示。每張圖片都以按比例縮略的方式展現(xiàn),點擊后彈出原圖片??s略圖功能是用Javascript實現(xiàn)的,比起用ASP代碼取得圖片尺寸再縮略的方法來得簡單方便,且無需擔心執(zhí)行ASP代碼時因未注冊asp組件而引起的IIS的崩潰。這段Javascript代碼如下:script language=JavaScript!var flag=false。function DrawImage(ImgD){var image=new Image()。=。if(0 amp。amp。 0){flag=true。if(= 160/120){if(160){ ==(*160)/。}else{=。 =。}=++。}else{if(120){ =120。=(*120)/。 }else{=。 =。}=++。}}} ///script3.3.1 榮譽資質(zhì)的實現(xiàn)需要用到的技術有循環(huán)讀取所有紀錄、分組換行、向Javascript函數(shù)傳遞參數(shù)、分頁顯示等功能。網(wǎng)頁截圖如下:圖33 榮譽資質(zhì)相關源代碼如下:%const MaxPerPage=15url=dim totalPut dim CurrentPagedim TotalPagesdim i,jif request(page) then currentPage=cint(request(page))else currentPage=1end ifsql=select * from [rongyu] order by pxSet rs= () sql,conn,1,1if not then totalPut= totalPut= if currentpage1 then currentpage=1 end if if (currentpage1)*MaxPerPagetotalput then if (totalPut mod MaxPerPage)=0 then currentpage= totalPut \ MaxPerPage else currentpage= totalPut \ MaxPerPage + 1 end if end if if currentPage=1 then showContent showpage totalput,MaxPerPage,url else if (currentPage1)*MaxPerPagetotalPut then (currentPage1)*MaxPerPage dim bookmark bookmark= showContent showpage totalput,MaxPerPage,url else currentPage=1 showContent showpage totalput,MaxPerPage,url end if end if end ifset rs=nothing sub showContentdim ii=0%% do while not %table width=100% border=0 cellspacing=0 cellpadding=0tr align=center valign=middle% for j=1 to 3 %td width=33%% if not and iMaxPerPage then %table width=202 border=0 cellspacing=0 cellpadding=0trtd align=center valign=toptable width=202 border=0 cellpadding=0 cellspacing=0trtd width=202 height=166 align=center valign=middle background=images/% if rs(img) then %a href=%=rs(img)% target=_blankimg src=%=rs(img)% width=160 height=120 border=0 onload=javascript:DrawImage(this)。 //a% end if %/td/tr/table/td/tr/table%i=i+1else amp。nbsp。end if%br //td% next %/tr/table%if i=MaxPerPage then exit doloopend sub%%function showpage(totalnumber,maxperpage,filename) dim n if totalnumber mod maxperpage=0 then n= totalnumber \ maxperpage else n= totalnumber \ maxperpage+1 end if img src=39。images/39。 width=39。30039。 height=39。3039。br共amp。totalnumberamp。條信息amp。nbsp。每頁顯示amp。maxperpageamp。條amp。nbsp。目前顯示第span class=39。zijuxi39。amp。CurrentPageamp。/span/amp。namp。頁amp。nbsp。amp。nbsp。 if CurrentPage2 then else amp。nbsp。amp。nbsp。a href=amp。filenameamp。?page=1首頁/a amp。nbsp。amp。nbsp。a href=amp。filenameamp。?page=amp。CurrentPage1amp。上一頁/a end if if ncurrentpage1 then else amp。nbsp。amp。nbsp。a href=amp。filenameamp。?page=amp。(CurrentPage+1)amp。下一頁/a amp。nbsp。amp。nbsp。a href=amp。filenameamp。?page=amp。namp。尾頁/a end ifend function %3.3.2 領導關懷的實現(xiàn)結(jié)構(gòu)和代碼與榮譽資質(zhì)模塊相同,只是添加了對每張圖片的簡要說明,并把每行顯示3張圖片改為只顯示2張圖片。改動部分的源代碼如下:% for j=1 to 2 %td width=50% val