毕业论文外文翻译--使用JavaScript设计网页(适用于毕业论文外文翻译+中英文对照)Word格式.docx

上传人:wj 文档编号:470007 上传时间:2023-04-29 格式:DOCX 页数:13 大小:22.12KB
下载 相关 举报
毕业论文外文翻译--使用JavaScript设计网页(适用于毕业论文外文翻译+中英文对照)Word格式.docx_第1页
第1页 / 共13页
毕业论文外文翻译--使用JavaScript设计网页(适用于毕业论文外文翻译+中英文对照)Word格式.docx_第2页
第2页 / 共13页
毕业论文外文翻译--使用JavaScript设计网页(适用于毕业论文外文翻译+中英文对照)Word格式.docx_第3页
第3页 / 共13页
毕业论文外文翻译--使用JavaScript设计网页(适用于毕业论文外文翻译+中英文对照)Word格式.docx_第4页
第4页 / 共13页
毕业论文外文翻译--使用JavaScript设计网页(适用于毕业论文外文翻译+中英文对照)Word格式.docx_第5页
第5页 / 共13页
毕业论文外文翻译--使用JavaScript设计网页(适用于毕业论文外文翻译+中英文对照)Word格式.docx_第6页
第6页 / 共13页
毕业论文外文翻译--使用JavaScript设计网页(适用于毕业论文外文翻译+中英文对照)Word格式.docx_第7页
第7页 / 共13页
毕业论文外文翻译--使用JavaScript设计网页(适用于毕业论文外文翻译+中英文对照)Word格式.docx_第8页
第8页 / 共13页
毕业论文外文翻译--使用JavaScript设计网页(适用于毕业论文外文翻译+中英文对照)Word格式.docx_第9页
第9页 / 共13页
毕业论文外文翻译--使用JavaScript设计网页(适用于毕业论文外文翻译+中英文对照)Word格式.docx_第10页
第10页 / 共13页
毕业论文外文翻译--使用JavaScript设计网页(适用于毕业论文外文翻译+中英文对照)Word格式.docx_第11页
第11页 / 共13页
毕业论文外文翻译--使用JavaScript设计网页(适用于毕业论文外文翻译+中英文对照)Word格式.docx_第12页
第12页 / 共13页
毕业论文外文翻译--使用JavaScript设计网页(适用于毕业论文外文翻译+中英文对照)Word格式.docx_第13页
第13页 / 共13页
亲,该文档总共13页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

毕业论文外文翻译--使用JavaScript设计网页(适用于毕业论文外文翻译+中英文对照)Word格式.docx

《毕业论文外文翻译--使用JavaScript设计网页(适用于毕业论文外文翻译+中英文对照)Word格式.docx》由会员分享,可在线阅读,更多相关《毕业论文外文翻译--使用JavaScript设计网页(适用于毕业论文外文翻译+中英文对照)Word格式.docx(13页珍藏版)》请在冰点文库上搜索。

毕业论文外文翻译--使用JavaScript设计网页(适用于毕业论文外文翻译+中英文对照)Word格式.docx

ALERTBOXES

TopopupanalertboxincludethefollowinglineofcodeinsideofscripttagsinthebodyofyourHTMLdocument.Pleasenotethattheprocessingofthepagewillstopuntiltheviewerrespondstothealertbox.

alert("

Placethetexttobedisplayedinthealertboxbetweenthesequotes.n)

Othertypesofpre-madedialogboxesareavailablesuchasthepromptandconfirmboxes.InordertotakefulladvantageofthefeaturesofthesedialogboxesyoumustwritemoreJavaScriptcodewhichcanusethevaluesthatarereturnedbythedialogboxes.

Thefollowingstatementswillpopupadialogboxthatrequiresayesornoanswer(OKorCancel).IftheanswerisOKthenthevariablenamedanswerhasavalueoftrueandiftheanswerisCancelthenthevariablenamedanswerhasavalueoffalse.YoucanthenuseanifstatementintheJavaScriptcodetorespondappropriately.

varanswer=confirm("

Areyousureyouwanttoquit?

"

if(answer==true)

window.close()

}

Thefollowingcodewillpopupadialogboxthataskstheusertoentersomesortofinformation.IftheuserclicksOKtheinformationtheyenteredisstoredinthevariable.Thesecondsetofquotationmarksinsideofthepromptstatementmakethecontentsofthetextboxblankwhenthedialogboxisdisplayed.

varresponse=prompt("

Whatisyourname?

document.write("

fontsize=7color=redface=arial>

Hello"

+response+"

”)

Noticethatinthelasttwoexamplesthewindowanddocumentobjectswereused.Windowreferstothebrowserwindowanddocumentreferstothepagebeingdisplayed.Theuseofadotafterthenameoftheobjectallowsactionstobeperformedonthatobjectorpropertiesofthatobjecttobemodified.Inthisnextexample,thenavigatorobjectisreferencedinordertodisplaythebrowsernameandversion.

Youareusing"

+navigator.appName+"

version"

+navigator.appVersion+

POP-UPWINDOWS

AnadditionalbrowserwindowmaybeopenedusingasimpleJavaScript.Theopenmethodcontainsthreepartsasinthefollowingexample:

thenameofthedocumentorurlofthewebsitetobedisplayedinthenewwindow,thenamethatmaybeusedtorefertothebrowserwindow(requiresmorecodethanisshownhere),andthepropertiesofthenewwindow.Pleasenotethatthepropertiesarealllistedinonesetofquotationmarksandareseparatedbycommas.

open("

myfile.html”,"

mywin”,"

height=200,width=200,titlebar=false"

Thefollowingpropertiesmaybeusedtocontroltheappearanceofthenewwindow:

Tablel-lpropertiesmaybeusedtocontroltheappearanceofthenewwindow

Feature

Example

Description

height

height=200

determinestheheightofthenewwindowinpixels

width

width=200

determinesthewidthofthenewwindowinpixels

titlebar

titlebar=false

removesthetitlebarfromthenewwindow

location

includestheurl/addresstextboxinthenewwindow

menubar

includesamenubarinthenewwindow

resize

resize=off

makesthenewwindowafixedsize

scrollbars

addsscrollbarstothenewwindow

status

includesastatusbarforthenewwindow

toolbar

toolbar=yes

addsatoolbarforthenewwindow

WRITINGFUNCTIONS

FunctionsaresmallsubprogramsthatarelocatedwithinscripttagsbetweentheheadtagsofanHTMLdocument.FunctionsareexecutedwhentheyarecalledbynamefromaneventhandlerwithinthebodyofanHTMLdocument.

Thebasicstructureofafunctionisasfollows:

functionNameOfFunction()

{

EVENTHANDLERS

Thefollowingexampledemonstratestheuseofeventhandleronclickaswellastheuseofstylestocontroltheappearanceofbuttons.Notethatinsteadofusingtype=submitforthebuttonthecodesimplysaystype=button.Copyandpastethisentiresetofcodeintoanewdocumentandtestitout.

html>

head>

title>

Sample<

/title>

styletype="

text/css"

#bigbutton(background-color:

yellow;

font-family:

arial;

color:

blue;

font-size:

18px;

height:

50px;

border-width:

0.2cm;

border-color:

red}

/style>

/head>

body>

formname=myform>

inputtype=buttonname=mybuttonid=bigbuttonvalue="

CLICKME!

onclick=,,window.location=,,n>

/form>

/body>

/html>

Changingthecodeforthebuttontoreadonclick="

myfunction()"

willresultinexactlythesamethingasthepreviousexampleifthefollowingfunctionisincludedinascriptbetweentheheadtags.Typically,youwouldwriteafunctiononlyiftheeventrequiredmorethanonethingtohappen.

functionmyfunction()

window.location="

Thefollowingaresomeoftheeventhandlersthatexistinjavascript:

Table1-2eventhandlersthatexistinjavascript

onfocus

onblur

onselect

onchange

onsubmit

onclick

onmouseover

onmouseout

onload

onunload

onabort

onerror

onreset

onkeypress

onkeyup

onmousedown

onmousemove

onmouseup

onmove

onresize

POP-UPMENUS

Pop-UpMenuscanbequicklycreatedbyusingtheselecttagasitwasusedinformstocreateadropdownlist.Setthevalueofeachoftheoptionsintheselecttagtotheurlofthenewpagetobedisplayed.Usetheonchangeeventhandlertosetthelocationofthewindowtotheselectedvalueinthedropdownlist.Forexample,iftheformisnamedmyform,theselecttagisnamedmychoices,andthevalueofeachoptionisaurlthenthestatementwindow.location=document.myform.mychoices.valuewilltakeyoutothenewpagethatwasselectedfromthedropdownlist.

Bydefaultonlyoneiteminalistisdisplayedbyaselectstatementuntiltheviewerclicksonthedownarrowtoexposetherestofthelist.Todisplaymorethatoneitematatime(andcreateatextboxwithaverticalscrollbar)includethesizeattributeintheselecttag.Forexample,size=5willdisplaythefirstfiveitemsinthelistandaddaverticalscrollbartotheboxiftherearemorethan5itemsinthelist.

MOUSEOVERS

Amouseoverreferstotheeffectthatoccurswhenthepropertiesofanobjectarechangedifthemouseispositionedoverthetopoftheobjectandthenagainifthemouseisremovedfromtheobject.Thequickestwaytogenerateamouseoveristousetheonmouseoverandonmouseouteventhandlersinaformofin-linestyle.

VisitthestylesectionoftheDHTMLpageofthiswebsitetoseeanexampleofmouseoversusedwithtextasanin-linestyle.Anystylepropertythatappliestoaparticularobjectcanbechangedastheresultofamouseover.

Performingmouseoverswithagraphicisnotmuchdifferentthanwithtext.Whenthedesiredeventoccurs(onmouseover,onmouseout)changethesourceofthegraphicasintheexamplethatfollows:

imgsrc="

picl.jpg"

onmouseover="

src=,pic2.jpgH,onmouseout="

src=,picl.jpg,n>

SCROLLINGTEXT

SincethemarqueetagisonlysupportedbyInternetExploreritisagoodideatoavoiditasmuchaspossibleanduseaJavaScripttogeneratescrollingtextinstead.WiththisJavaScriptitisalsoquiteeasytoplacethescrollingtextonthestatusbarinsteadofinthedocumentitselfbyusingwindow.statusasthedestinationforthemessage.Thefollowingfunctionwillgenerateascrollingmessageinatextboxnamedmymessageboxwhichispartofaformnamedmyform.Theeventhandleronloadmustalsobeusedinthebodytagtocallthefunctionwhenthepageloads.

varmessage="

Thisisatest..."

varposition=0

functionmymessage()

document.myform.mymessagebox.value=

message.substring(position,message.length)+

message.substring(O,position)

position=position+1

if(position>

message.length)

position=0

window.setTimeout("

mymessage()”,300)

DATESANDTIMES

Datesandtimesareoftendisplayedonwebpagestoindicatewhenapagewaslastupdated,whenapagewasloaded,ortodisplayacountdowntoaparticularevent.Displayingthedateandtimeofthelastupdateisagoodpracticetogetintoforallofyourpagesbecausefrequentupdatesareonesignofaqualitysite.Thedate/timestampletstheviewerknowhowrecenttheinformationisandthereforeprovidesoneindicationofvalidity.Todisplaythedateandtimeofthelastupdate(thelasttimethedocumentwassaved)usethefollowingonelineinsideofscripttags:

Thispagelastupdated”+document.lastModified)

TodisplaythecurrenttimeanddateonawebpageyoumustdeclareavariableoftypeDate(varnow=newDate).Thevariablecanthenbeusedtoaccessvariouspartsofthedateandtimeincludingdayoftheweek,month,dayofthemonth,year,hours(inmilitarytime),minutes,andseconds.AssumingthatnowisthevariabledeclaredoftypeDatethefol

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2