javascript第二章

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

HTMLDOM:HTML文档对象模型,是w3c国际组织的一套web标准。它定义了访问HTML文档对象的一套属性,方法和事件。htmlheadtitleNewDocument/titlescripttype=text/javascriptfunctionchangeLink(){document.getElementById('myAnchor').innerHTML=百度;document.getElementById('myAnchor').href=}/script/headbodyAid=myAnchorhref=淘宝/Ainputtype=buttononclick=changeLink()value=使用DOM改变链接/body/html设置ID并用document.getElementById()就可以访问定位:window.document.myform.text1;省略window:document.myform.text1location和history分别对应IE浏览器中的地址栏和前进/后退按钮window对象:window对象的常用事件:onload表示在窗口或框架完成文档加载时触发。如:弹出式广告。htmlheadtitleNewDocument/titlescriptlanguage=javascriptfunctionopenwindow(){window.status=您正在注册......;if(window.screen.width=1280&&window.screen.height==800)window.open(1.html);elsewindow.alter(请设置分辨率为1024*768,然后再打开);}functionclosewindow(){if(window.confirm(您确定要退出系统吗?))window.close();}/script/headbodybgcolor=#CCCCCCtableborder=0align=centerbgcolor=#FFFFFFtrtdimgsrc=images/head.jpgwidth=761height=389/td/trtrtdimgsrc=images/foot.jpgwidth=502height=90align=topinputtype=buttonname=regButtonvalue=用户注册onclick=openwindow()inputtype=buttonname=exitButtonvalue=退出onclick=closewindow()/td/tr/table/body/html一般window会省略不写。htmlheadtitleNewDocument/titlescriptlanguage=javascriptfunctionopenwindow(){open(2.html,注册窗口,toolbars=0,location=0,statusbars=0,menubars=0,width=700,height=550,scrollbars=1);}functionclosewindow(){if(window.confirm(您确定要退出系统吗?))window.close();}/script/headbodybgcolor=#CCCCCConload=openwindow()tableborder=0align=centerbgcolor=#FFFFFFtrtdimgsrc=images/head.jpgwidth=761height=389/td/trtrtdimgsrc=images/foot.jpgwidth=502height=90align=topinputtype=buttonname=regButtonvalue=用户注册onclick=openwindow()inputtype=buttonname=exitButtonvalue=退出onclick=closewindow()/td/tr/table/body/htmlshowModalDialog()方法的功能:htmlheadtitleNewDocument/titlescriptlanguage=javascriptwindow.showModalDialog(2.html,”zcck,toolbars=0,location=0,statusbars=0,menubars=0,width=700,height=550,scrollbars=1);functionclosewindow(){if(window.confirm(您确定要退出系统吗?))window.close();}/script/headbodybgcolor=#CCCCCConload=openwindow()tableborder=0align=centerbgcolor=#FFFFFFtrtdimgsrc=images/head.jpgwidth=761height=389/td/trtrtdimgsrc=images/foot.jpgwidth=502height=90align=topinputtype=buttonname=regButtonvalue=用户注册onclick=openwindow()inputtype=buttonname=exitButtonvalue=退出onclick=closewindow()/tdtdwidth=86valign=toph3ahref=javascript:openwindow()用户注册/a/h3/tdtdwidth=86valign=toph3ahref=javascript:closewindow()退出/a/h3/td/tr/table/body/htmlvar日期对象=newDate(参数);vartoday=newDate();MMDD,YYYY,hh:mm:ssvartdate=newDate(“July29,2008,10:30:00”);HTMLHEADTITLENewDocument/TITLESCRIPTlanguage=JavaScriptfunctiondisptime(){varnow=newDate();varhour=now.getHours();if(hour=0&&hour=12)document.write(H2上午好!/H2);if(hour12&&hour=18)document.write(H2下午好!/H2);if(hour18&&hour24)document.write(H2晚上好!/H2);document.write(H2今天日期:+now.getYear()+年+(now.getMonth()+1)+月+now.getDate()+日/H2);document.write(H2现在时间:+now.getHours()+点+now.getMinutes()+分/H2);}/SCRIPT/headBODYonload=disptime()/BODY/HTMLsetTimeout(“disptime()”,1000);HTMLHEADTITLENewDocument/TITLESCRIPTlanguage=JavaScriptfunctiondisptime(){vartime=newDate();varhour=time.getHours();varminute=time.getMinutes();varsecond=time.getSeconds();document.myform.myclock.value=hour+:+minute+:+second+;varmyTime=setTimeout(disptime(),1000);}/SCRIPTstyletype=text/cssINPUT{font-size:30px;border-style:none;background-color:#FFBB3B;}/style/headBODYonload=disptime()formname=myformtablewidth=100%border=0align=centertrtdcolspan=3imgsrc=images/mosou.jpgwidth=1001height=457/td/trtrtdwidth=37% /tdtdwidth=41%h2当前时间:inputname=myclocktype=textvalue=size=10/h2/tdtdwidth=22% /td/tr/table/form/BODY/HTMLhistory对象:location对象:htmlheadtitleNewDocument/title/headbodyahref=javascript:history.back()返回/aahref=javascript:history.forward()前进/aahref=javascript:location.reload()刷新/aselectname=selTopicid=selPTopiconChange=javascript:location=this.valueoptionvalue=2.html新闻贴图/optionoptionvalue=3.html网上谈兵/optionoptionvalue=4.htmlselected教育大家谈/option/body/html

1 / 7
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功