實(shí)驗(yàn)一web客戶(hù)端編程1_第1頁(yè)
實(shí)驗(yàn)一web客戶(hù)端編程1_第2頁(yè)
實(shí)驗(yàn)一web客戶(hù)端編程1_第3頁(yè)
實(shí)驗(yàn)一web客戶(hù)端編程1_第4頁(yè)
實(shí)驗(yàn)一web客戶(hù)端編程1_第5頁(yè)
已閱讀5頁(yè),還剩1頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、網(wǎng)絡(luò)112班3110757214陳宇鵬實(shí)驗(yàn)一 web客戶(hù)端編程一、實(shí)驗(yàn)?zāi)康募耙笫褂胔tml超文本標(biāo)記語(yǔ)言制作簡(jiǎn)單頁(yè)面,要求通過(guò)實(shí)驗(yàn)?zāi)軌蛘莆説tml 文件的基本結(jié)構(gòu)和文檔的創(chuàng)建、編輯及保存。驗(yàn)證并掌握html超文本標(biāo)記語(yǔ)言的文本、圖像、超鏈接、表格、表單等 標(biāo)記的使用。通過(guò)實(shí)驗(yàn)掌握層疊樣式表css的創(chuàng)建及應(yīng)用,掌握在網(wǎng)頁(yè)屮插入層疊樣式 表css的常用方法,掌握層疊樣式表css的主要基本屬性的使用。通過(guò)實(shí)驗(yàn)了解javascript的編程規(guī)范及基木語(yǔ)法,能夠分析javascript程序 的功能,可以在網(wǎng)頁(yè)制作屮使用javascript程序。通過(guò)實(shí)驗(yàn)了解ajax的編程方法,掌握ajax編程技巧。二、

2、實(shí)驗(yàn)內(nèi)容及步驟1) 請(qǐng)參考教材的第2-4章內(nèi)容,認(rèn)真閱讀分發(fā)的源代碼,并根據(jù)教材上的 提示,完成源代碼中沒(méi)有實(shí)現(xiàn)的功能。2) 開(kāi)發(fā)一個(gè)用戶(hù)注冊(cè)界而,要求:用戶(hù)名基于ajax檢測(cè)是否重復(fù),年齡需用javascript檢查格式是否正確。三、實(shí)驗(yàn)過(guò)程及結(jié)果1.編寫(xiě)用于顯示的jsp頁(yè)而,代碼如下<body background=nhjpgh><hl align="centern> <font color="red'*> 咳咳注冊(cè)會(huì)員</font></hl><form name=n formln action=

3、fl n><table align=n center”><tr>vtd用戶(hù)名</td><td><inputtype=fltexthname=nuser nmme”id=nusernamen onblur=ncheckuser () !,/></td><tdxdiv id=ninfonx/div></td></tr><tr><td>5</td><tdxinputtype=f, pas sword11name=,f pas sword11id=

4、hpasswordn /></td></tr><tr><td>確認(rèn)密碼</td><td><inputtype=n pas sword11name=fl repms sword”id=nrepassword11 onblur=11 checkpassword () 11 /></td></tr><tr><td年齡 </td><td><input type=ntextn name=uageh id=hagen /></td&g

5、t; </tr><tr><td><input type=nsubmitn value=niifflfn/></td><tdxinput type=f,resetn value=,f,f /></td> </tr></table></form>顯示的頁(yè)面如下:性別: 年熟 地 e: 手機(jī)尋歡迎注冊(cè)神盾局會(huì)員2 編寫(xiě)ajax用于判斷用戶(hù)名是否存在function checkuser()var uname = document.getelementbyid(nusernameh )

6、 .value;if (uname = ”)alert (n用戶(hù)名能為空”);documentgetelementbyld(husernamen) focus ();return ;var http;if (window.xmlhttprequest)http = new xmlhttprequest();elsehttp = new activexobjectmicrosoftxmlhttpn);http.onreadystatechange= function ()if(http.readystate =4 && http.stutus = 200)(var str = h

7、ttp.responsetext;if (str = "success”)document. getelementby id (*' inf o*') . innerhtml='* jij 戶(hù) 名不可用“;document getelementbyld ( musername,f) . focus ();elsedocument. getelementbyld (*' info*') . innerhtml='* jij 戶(hù) 名可用"url = ncheck?username=h +uname;httpopen ( ngetn

8、 f url,true);httpsend();3 .編寫(xiě)javascript分別判斷兩次輸入密碼是否正確function checkpassword()varvar password = document.getelementbyld("password”).value; repassworddocument getelementbyid (,f repassword11) . value;if (password = n n) alert (n請(qǐng)輸入密碼”);documentgetelementbyid("password”) focus ();return ;if (

9、password != repassword) alert (”輸入的密碼不一致,請(qǐng)重新輸入”);document. getelementbyid (,fpasswordh ) focus ();4.判斷年齡是否正確function checkage()var age = document.getelementbyid(hagen).value;if (age<l0&&age>100) alert (li輸入年齡范圍應(yīng)該為10歲至100歲“);document.getelementbyld(nagen) .focus ();return false;5 編寫(xiě)一個(gè)se

10、rvlet,用于判斷客戶(hù)端傳過(guò)來(lái)的用戶(hù)名是否已經(jīng)在服務(wù)器端存在,這里沒(méi)有 使用數(shù)據(jù)庫(kù),只是采用一個(gè)字符串?dāng)?shù)組。static st ring name = n zhangsan11 , n 1 i s i n , nwangwun ;publicvoiddoget(httpservletrequestrequest,httpservletresponse response)throws servletexception, ioexception string result = nfailuren;response setcoriterittype ( ntext/html” );printwri

11、ter out = response.getwriter ();string username = request.getparameter(nusernamen);for(int i=0 ; i < name.length; i+)if (usernameequals(namei)result = "success"break;out.write(result);outflush ();outclose ();四、思考并回答問(wèn)題(1)超文本標(biāo)記語(yǔ)言的文檔主要由哪些標(biāo)記構(gòu)成?缺少任何一部份會(huì)對(duì)文 件產(chǎn)生什么影響?不帶任何標(biāo)記的文檔又會(huì)怎樣?答:html <hcad><body><form>(2)要想使瀏覽器屮顯示的文字分行排列,應(yīng)使用何種標(biāo)記處理?答:用<table> <tr><td><th>

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論