JavaScript教程 解释型或即时编译型的编程语言.docx

上传人:夺命阿水 文档编号:1415058 上传时间:2024-06-15 格式:DOCX 页数:77 大小:87.38KB
返回 下载 相关 举报
JavaScript教程 解释型或即时编译型的编程语言.docx_第1页
第1页 / 共77页
JavaScript教程 解释型或即时编译型的编程语言.docx_第2页
第2页 / 共77页
JavaScript教程 解释型或即时编译型的编程语言.docx_第3页
第3页 / 共77页
JavaScript教程 解释型或即时编译型的编程语言.docx_第4页
第4页 / 共77页
JavaScript教程 解释型或即时编译型的编程语言.docx_第5页
第5页 / 共77页
点击查看更多>>
资源描述

《JavaScript教程 解释型或即时编译型的编程语言.docx》由会员分享,可在线阅读,更多相关《JavaScript教程 解释型或即时编译型的编程语言.docx(77页珍藏版)》请在课桌文档上搜索。

1、JavaScript.1.Thau!CGI一Javascript,CGIavascript-WEB-JavascriptJavascript,_-Perl,C,C+JavaJavasript.Page1:Javascript.Page2:.Page3:-Page4:.JaVaSCriPtPage5:-2.:.Thau!-3Javascript.Javascript一JavascriptQ.if-then.JavasriptJavaJavascriptJavascriptJavascript-Javascript-3.0一3d-Javascript.Javascript.1.:Javascrip

2、t.2.:.3.:.4.:.JavaScript.5.:.3.:.Thau!JavaScript,.HTM1.JavaScript-HTM1.-JavaScript.HTMI_一JavaScript.scriptIanguage=nJavaScriptnX.Ianguage=zzJavaScriptzz.JavaScript一J1.*alert(better,stronger,faster,.Javascript._.1.:Javascript.2.:.3.:.4.:JaVaSCriPt.5.:-.4.JavaScript.Thau!,JTM1.JavaScript- /putupanaler

3、tbox,toshowhowtheyworkalert(Soo,IW川OVerthrOWmybrowser!);第2章Congratulations.,.HTM1. blahblahblah!-hidethisstufffromotherbrowsers.1.:Javascript.3:r;.JaVaSCriPt5,:-.5.:.Thau!JavaScript. JavaScript. JavaScript. JavaScript- Q JavaScript.JavaScriptJavaScript JavaScript. JavaScript. JavaScript.Page1:Javasc

4、ript.Page2:.Page3:.Page4:.JaVaSCriPtPage5:.JavaScript2.Thau!JavaScript-JavaScript一l2.::3Q.4.:.5.:.6.:if-then.7.:if-then.8.:if-then.9.:.10.:.11.:2.12.:.Thau!JavaScript-x=21xy=x+31,y,-5.-JavaScript.JavaScript.JavaScriptJavaScript.l2.:r3A:.5.:.6.:if-then.7.:if-then.8:if-then.9.:.10.:.11.:温.12.:._.Thau!

5、一hidemeJavaScript./here,showtouseJavaScripttowriteoutHTM1.document,writein(zzThemonkeydances);document,writein(secs_per_year);document,writein(,secondsperyear,zz);document.writeln().document,writeln().jdocument.writein(blah!)JHTM1.secs_per_year.JavaScript-_secs_per_yearJavaScriptJavaScript(,document

6、.write1n(zzsecs_peryearz,).JavaScript.secs_per_year_31,536,000.document,writeInO.HTM1.-JavaScript.(secs_per_min).secs_per_minJavaScript.document,writein(secs_per_min).JavaScript.Ir2.:,3.l.4.:.5.:.6.:if-then.7.:if-then.8.:if-then.9.:.10.:.11.:2.12.:r.4.Thau!varnice_monkey=Themonkeysmilesatyouandrecit

7、esShakespeare.varbad_monkey=Themonkeyscowlsatyouandburps.;document,writein(nice_monkey);varmonkey=prompt(z,What,sthemonkey,sname?,Themonkeyz,);-OK.-Whatsthemonkeysname?Themonkey1.varmonkey=prompt(zzWhat,sthemonkey*sname?,);vartechymonkey=monkey+demanding+tech;zrtechymonkeyThemonkey+demands,no,insist

8、suponreceiving+acomputerthatwon,tcrash,andahomemadebrowser!vartechy_monkey-monkey+demandingtech;vartechy_monkey-Themonkeydemands,no,insistsuponreceivingacomputerthatwon,tcrash,andahomemadebrowser!,;varitalic_hippy=hippy_monkey.italics();varshouting-hippy=hippy_monkey.toUpperCase();varred_bold_tech-b

9、old_tech.fontcolor(,red,);varitalic_hippy=+hippymonkey+”;JavaScript.document.writein(italic_hippy).JHTM1.-hippymonkey.string,fontcolor(,newcolor,)varred_bold_tech=zz+bold_tech+;varred_bold_tech-bold_tech.fontcolor(,red,);document,writein(bold_tech+);varbrokenbold=bold_tech+”;document,writein(brokenb

10、old);2:,.4.:.5.:.6.:if-then.7.:if-lhen-B.:if-then,.9.:.10.:r.11.:z2.12.:r5二.Thau!.HTM1.andj11ad-lib.51if-the.l2.:.3j.4.:.5.:.6.:if-then.7.:if-then.8.:if-then.9.:.10.:r.11.:J.12.:.6Jif-then.Thau!if-then_if(someconditionistrue)(dosomething;dosomething;dosomething;.if,(if.).-if-then-.if-then.1,2.::3.1.

11、4.:.5.:-.6.:if-then.7.:if-then.8.:if-then.9.:.10.:r.11.:2.12.:r.7.if-then.Thau!.yes.varmonkey_love=prompt(,zDoyoulovethemonkey?,Typeyesorno);if(monkey_love=yes)alert(zzWelcome!msogladyoucame!Please,readOri!);)Jnonkey_love_jnonkey_love.yes.JavaScriptJ11onkey-love.yes.(variable_lvariable_2)istrueifvar

12、iable_lisgreaterthanvariable_2(variable_lvariable_2)istrueifvariable_lislessthanvariable_2(variable_218)&(variable121)document,writeIn(/zvariable_lcanvote,butcan,tdrink.);.&JavaScript一if(variable-l=bananas)(variable_l=JavaScript)document,writein(,zThemonkeyishappybecauseithas+variable_l);.if-then.!2

13、: .?3:4: ,.6.:if-then.7.:if-then.B.:if-hen.9.1.10.:r.11.:z2.12.:8.:if-thenExercise.Thau!广.1,.2.:.4.:.5.:.6.:if-then.7.:if-then.8.:if-then.9.:.10.:.11,:.2.12.:r.Tha!JavaScriptonClick,一OnMoUSeoVer._.onClick.onMouseOver.JavaScripts-JavaScripts-JavaScripts-OnClick-Clickonme!-OnCIiCk二JavaScriptsalert_JIr

14、ef=_Mouseoverme!.OnMouseOver.onClick.2.:r.4.:.S:.6.:if-then.7.:if-hen.B.:if-then.9.:.10.:r.11.:/.12.:.10.:.Thau!OneofthemostcommonlyusedfeaturesofJavaScriptistheabilitytochangeimagesonamouseover.Unfortunately,MicrosoftInternetExplorer3.0doesnotsupportimagereplacement.SoifyoureusingIE3.Ozitmightbetim

15、etoupgradetoIE4.0orswitchtoNetscape.JavaScripts-.IE3.0-IE4.0.Netscape3.0.1.etsgothroughtheexamplestepbystep.ThefirstlineofinterestisThisisjustlikeaStandardexceptthisonehasbeengivenaname:Thisnamecouldbeanything:my_image,a_boxzwhatever-butitcanthaveanyspacesinit.the_image.my_image,a_boxz.Thenextlineof

16、interestischangeThisiswheretheimageswaphappens.Itsjustliketheousawbefore.TheactivepieceofJavaScript,whichappearsinthequotesoftheisthis:OnMouseOver.onMouseOver.JavaScript.document.thejmage.src=,button-d.gif,;ThisstatementsayszfindtheimagecalledandchangeitstoNotethattherearedoublequotesaroundthewholes

17、tatement,andtakessinglequotes.Althoughquotesareinterchangable,ifyouhaveonesetofquotesinsideanothersetofquotes,thesetshavetobeofdifferentkinds.SoyoucouldeitherdobutnotGotit?Jthe-image,.src.button_d.gif._竺Utton_d.gif_.something.something,.,something,orsomething,1.Justastherewasalotofdetailinwhatmakesd

18、ocument,writein()work,mnottellingyouexactlyhowthisimageswapisworking.Youlllearnthedetailsofbothwhenwelookatobject-orientedprogrammingandtheDocumentObjectModelinthenextlesson.document,writein().Animportantcaveataboutimageswappingisthattheimageyoureswitchingtoshouldbethesamesizeastheoriginal.Ifitsnot,

19、itllgetsmashedorstretchedtofittheoriginalssize.Ir2,:,3?if-then.if-thenif-then.A.:,.6.:i.7.:iB.:i.9.:.10.11.12.11.;2.Thau!3.IE2.:r3.14:.5.:.6.:if-hen.7.:if-thenB.:if-then.9.:.10.:r.11,:.2.12.:.12.:.Thau!document.writeln().document,writeinO.HTM1.prompt.prompt.if-then-else.if-then-else.JavaScript.href.

20、onClick.OnMouseOver.JavaScript.:JavaScriptJavaScript.frames,.lr2.:3.1.4.:.5.:.6.:if-then.7.:if-then.8.:if-then.9.:.10.:.11,:.2.12.:r.5.:.Thau!ljavascript.ThaUJaVaSCriPt.ThauJavaScript1.ThaUJaVaSCriPt.,.JavaScript”ThaUJaVaSeriPt.ThaUJaVaSCriPt.1.rJHTM1.andj11ad-lib.1.if-then-.l.2.:.4,:.5.:.6.:ifthen.

21、7.:if-then-.8.:if-then.9.:.10.:.11.:.12.:rJavaScript.3.Thau! JavaScript.HTM1. .JavaScript.HTM1. JavaScript,if-then._window,document,monkeyimage,src二,happymonkey,gifz,Jiappymonkey,gif.monkeyimage._window.document.?.src.?.,.document.Writel.n(monkey).document,writein.writeIn?-(JavaScriptDocumentObjectM

22、ode1.DOMDOM.JavaScript.JavaScript二DOM.JavaScript-DOM.,JavaScript.1423:.=.4.:JavaScript.5.:WindoWS.6.:JaVaSCriPt-.7.:.8.:.9.:JaVaSCriPtDoM.10.Window.Frame.11.12.13.2j.Thau!JavaScript-HTMI_,.href_HTM1.:clickingonthislinkwillopenanotherwindow.Jyer_new_windowyer_new_window1.herf.URIHTM1._yer_newwindow.2

23、%3.::A:.5.:.6.:.href.,JavaScript.JavaScript.WindOwS.JaVaSCriPt-.7.:(8.:.9.::.10.11.12.13.JaVaSCriPtDoM.Window.Frame.3JavaScript.Thau!.HTMIJavaScript-window.OPen(UR1.,name,features);-UR1.-UR1.http:WwW.hotwired,com/WCbnlOnkey”.UR1.-ope-.features-JavaScript.1.,3.:.4.:.5J.6.:;.7.:.8.:.9.:JavaScript.Wind

24、OWS.JaVaSCriPtJavaScriptDOM.11.12.13.Window.Frame.4j.Jav_.Thau!.javascript_l-.javascript_2.javascript_l.HTM1.Here,sawindownamedjavascript_l,.javascript-l.javascript_window_l.html.features-.onClick-window,open().onClick-.windows.open().-HTM1.Here,sawindownamedjavascript_2.-HTMIjavascript_l.Here,sanot

25、herHTM1.pagegoingintojavascriptl.-featuresOK.windowsfeaturesJ.1.2 .1.3 :=.4.:JavaScript.5.:Windows,.6.:JavaScript.7.:.B.:.9.:JaVaSCriPtDOM.10.:r.11.:.WindOW.Frame.12.:?.13.:r5.Thau!window,open()window.OPer1(Someur1,“windowname,location,menubarzz);-URIwindow,open(z,someurlz,windowname,location,height

26、=100,width=100z,);-100-menubar.status.一URl_marqueescrollbars.resizable.width.heighttoolbar.Homebutton,amongothers.-HOME.location.UR1.directories.2.3.4.5.6.7.8.Netscape.Whatsnew,Whatscool,.JavaScript.WindOWS.JaVaSCriPt-.9.:JaVaSCriPtDoM.10.:r.11.:,Window.Frame.12.:r.13.:.6JavaScriptDOM.Thau!-JavaScri

27、ptDOM-.-JavaScript.-JavaScriptJavaScript-Window-一UR1.-JavaScript-window-varthe_status=window,status;.windowstatus-the_status-status_window,status=Tmmonkeyingaround!,;.1.23.4.5.6.7.8.9JavaScript.Windows.JavaScript,JaVaSCriPtDOM.10.11.12.13.Window.Frame.Tha!错误!超级链接引用无效。错误I超级链接引用无效。Whodowelove?.widow.o

28、pen(UR1.,ame,features)Javascriptjpen-varitalic_hippy=hippy_monkey.italics();-italics().一alert.prompt一window,alert(,Vivalaprimate!,7);-VivaIaprimate!.错误!超级链接引用无效。Itseemssortofsillytojustblurthewindowthatyourelookingat.Inordertousefocusandblurmoreusefully,youneedtoknowhowtoinvokemethodCaIlSonotherwind

29、ows.1423 :M.4.:JavaScript.5.:WindOWS.6.:JaVaSCriPt-.7.:.4 .:-.9.:JaVaSCriPtDOM.10.:.11.:.Window.Frame.12.:r.13.:r-.Thau!-javascript.varnew_window=window,open(zzhello.html”,htm1.name“width=200,height=200/z);_newwindow.new_window_JIeW.window.newwindow.:newwindow,blur();.window,blurO.BringitforwardPuti

30、tbackward.l.?2-3:=.4.:JavaScript.5.:WindoWS.6.:JaVaSCriPt.7.:,.8.:.9.:JavaScriptDOM.10.:r.11.:,WindOvV.Frame.12.:s.13.:.9二.Thau!JavaScript-document.HTM1.-document-imageswap)change.window.document.the_image3rc-butt0n.d.gif.windows.d。CUmentStodOCUmenl.images.-JavaScript.DocumentObjectMode1.2.1.3.:4.::

31、5二.6.::JavaScript.WindOWS.7.:,8.::.9.:.10.11.12.13.JaVaSCriPtDoM.WindoW.Frame.JaVaSCriPt-0.:.Thau!FramesAreaPicnic.JavaScript-javascript-.javascript-control_frame,.-javascript.HTM1.-src=#.:COntrO1_frame_ahref=#onClick=z,top.targetframe,document,writeln(,Monkeydo!);”MonkeyseeJavaScript-_target_frame.

32、docume1.JavaScript-document.writelnOJ1Monkeydo!.writeln().document-.document.writein().writein().*U2。3:=.4.:JavaScript.5.:Windows.6.:JavaScript,.7.:.B.:-.9.:JaVaSCriPtDOM.10.:?.11.:.Window.Frame.12.:r.13.:.11.:-.Thau!-top.-top.zparent.-2-parent.一javascript.1.?2,3.:.4.::.5.1.6.:.7.:.8.:.9.:JavaScript

33、.Windows.JaVaSCriPt-JaVaSCriPtDoM.10.:.11.:.WindoW.Frame-.12.:?.13.:.12.:.Thau!-2-.document-bgco1O-HTM1.body.document.“red:.16.#FFoOO0JavaScript-3.1.,2;3.:=.4JavaScript.5.:Windows.6.:JaVaSCriPt-.7.:-.8.:.9.:JaVaSCriPtDoM.10.:-.11.:.WindOW.Frame.12.:r.13.:.13.:.Thau!DocumentObjectMode1.JavaScript.-Do

34、mainObjectModel)-DOM.-HTM1.1.,2.3.:.4.:.5.:.6.:.7.:.8.:.9.:JavaScript-Windows.JaVaSCriPtJaVaSCriPtDoM.10.:r.11.:Window.Frame.12.:.13.:=Javascript.:.Thau!Javascript_2Jf-then-Javascript-Javascript_Page1:-Page2:.Page3:.Page4:.WHI1.E.Page5:-Page6:.Page7:.Page8:.Page9:.PageIOlPage11:.Page12:-Page13:.Page

35、14:-.Thau!varthe_password=passthewrench;varanswer=prompt(What,sthewoyd?/);if(answer!=the_password)answer=prompt(,Whatsthewoyd?,);if(password!=the_password)document.write(Youlose!);elsedocument.write(That,sright!);elsedocument.write(,That,sright!);if-then.(loop)while.passthewrench.1.:.2.:r3.:.4,:.WHI

36、1.E.5.:For.6.:,.7.:.8.:.9.:.10.11.:r.12.:,.13.:,.14.”.Thau!Javascript-varpassword=passthewrench;varanswer;-answer一answer.while(answer!=password)answer=prompt(Whatsthewoyd?/);.while.while-while(sometestistrue)dothestuffinsidethecurlybraces.answer.Password(Passthewrench)-(aswer!=password)-answe1.while-answer-answer-.1.:.2.:?3:.4.:.WHI1.E.5.:For.6.:.7zr.8.:.9.:.10.11.:r.12.:?.13.:,.14.:r.4.While1.oops.Thau!varwidth=prompt(z,Howmany,swouldyoulike?(1-10isgood)”,5);vara_line=;varloop=0;while(loopwidth)(a_line=a_line+x;loop=loop+l;alert(a_line);while(loopwidth)(a_line+=x

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

当前位置:首页 > 在线阅读 > 生活休闲


备案号:宁ICP备20000045号-1

经营许可证:宁B2-20210002

宁公网安备 64010402000986号