Dom课件.ppt

上传人:b****2 文档编号:2657001 上传时间:2022-11-05 格式:PPT 页数:79 大小:325KB
下载 相关 举报
Dom课件.ppt_第1页
第1页 / 共79页
Dom课件.ppt_第2页
第2页 / 共79页
Dom课件.ppt_第3页
第3页 / 共79页
Dom课件.ppt_第4页
第4页 / 共79页
Dom课件.ppt_第5页
第5页 / 共79页
点击查看更多>>
下载资源
资源描述

Dom课件.ppt

《Dom课件.ppt》由会员分享,可在线阅读,更多相关《Dom课件.ppt(79页珍藏版)》请在冰豆网上搜索。

Dom课件.ppt

第二节第二节DOM编程编程DHTMLwindow对象对象document对象对象body对象对象form对象对象form表单字段元素对象表单字段元素对象DHTML1.JAVASCRIPT将浏览器本身、网页文档、以及网页文档中的HTML元素等都用相应的内置对象来表示,这些对象及对象之间的层次关系称为DOM(DocumentObjectModel,文档对象模型)。

2.css、脚本编程语言和DOM的结合使用,能够使HTML文档与用户具有交互性和动态变换性,这三种技术的单一称谓叫DHTML(DynamicHTML,动态HTML).事件事件事件:

用户对浏览器所做的特定的动作(操作),是实现交互操作的一种机制。

事件处理程序:

浏览器响应某个事件,实现用户的交互操作而进行的处理(过程)。

事件处理程序的调用:

浏览器等待用户的交互操作,并在事件发生时,自动调用事件处理程序(函数),完成事件处理过程。

Click/DblClick、KeyDown/KeyPress/KeyUp、Load/Unload、MouseDown/MouseUp/MouseOver/MouseOut/MouseMove如何编写事件处理程序如何编写事件处理程序一、在事件源对象所对应的HTML标签上增加一个要处理事件属性,让事件属性值等于处理事件的函数名或程序代码。

格式:

tagon事件=“|”例1:

例2:

functionshow()varstr=建议浏览器的分辨率:

800x600;alert(str);二、直接在JavaScript代码中,设置元素对象的事件属性,让事件属性值等于处理该事件的函数名或程序代码。

格式:

对象名.on事件=|例1:

document.onload=alert(建议浏览器的分辨率:

800x600);varstr=建议浏览器的分辨率:

800x600;document.onload=alert(str);例2:

functionshow()varstr=建议浏览器的分辨率:

800x600;alert(str);document.onload=show();例1:

请输入基本资料:

姓名:

例2:

functionhandelError(img)msg=有一图文件,名为:

+img.name+n无法顺利显示,请通知系统管理人员+,敬备薄礼相送。

;alert(msg);例3:

varurl=newArray(3);url0=http:

/www.yam.org.tw/;url1=http:

/space_num=0;vardir=1;functionscroll()space_num=space_num+1*dir;if(space_num40|space_num=0)dir=-1*dir;for(varfor(vari=0;ii=0;ispace_numspace_num;i+);i+)str_pacestr_pace+=;+=;varvarstr_spacestr_space=;=;window.statuswindow.status=str_space+str_space+functionstart()functionstart()setInterval(scrollsetInterval(scroll(),100);(),100);body(),100);information.htmlwindow.setTimeout(window.close(),5000);window.setInterval(grow(),100);functiongrow()window.resizeBy(5,5);functioncloseit()window.close();opener.start();/or/window.setTimeout(window.closeit(),5000);/通知5秒钟以后,这个窗口会自动关闭!

window对象事件专用事件:

onload事件onunload事件onbeforeunload事件通用事件onclick事件onmousemove事件onmouseover事件onmouseout事件onmousedown事件onmouseup事件onkeydown事件onkeyup事件onkeypress事件window_event.html2alert(ok2);1helloalert(ok3);alert(ok1);window对象对象属性location对象event对象frames数组对象screen对象clipboardDate对象history对象navigator对象document对象window对象location对象window.location.htef=http:

/方法方法Write方法方法writeln方法方法open方法方法close方法方法clear方法方法getElementById方法方法getElementByName方法方法getElementByTagname方法方法createElement方法方法createStyleSheet方法方法这是最初的内容document.write(这是write方法动态写入的内容);functionupdatedoc()document.writeln(abc);document.writeln(def);document.close();varowin=window.open(,_blank);owin.document.writeln(xyz);owin.document.close();owin.document.write(abc);owin.document.write(def);owin.document.close();这是最初的内容document.write(这是write方法动态写入的内容);functionupdatedoc()document.writeln(abc);document.writeln(def);document.writeln();document.writeln(functionupdatedoc();document.writeln();document.writeln(document.writeln(abc););document.writeln(document.writeln(def););document.writeln();document.writeln();document.writeln();/document.close();/*document.writeln(abc);document.writeln(def);document.close();varowin=window.open(,_blank);owin.document.writeln(xyz);owin.document.close();owin.document.write(abc);owin.document.write(def);owin.document.close();*/Document对象属性对象属性与与标签相关的属性标签相关的属性alinkColor属性linkColor属性vlinkColor属性bgColor属性fgColor属性描述网页文档信息的属性charset属性defaultCharset属性cookie属性fileCreatedDate属性fileModifiedDate属性fileSize属性lastmodified属性url属性URLUnencoded属性referrer属性a.Htmlb.htmldocument.refererfunctionchangeDoc()document.bgColor=blue;document.fgColor=red;document.alinkColor=yellow;document.vlinkColor=0x00ff00;document.linkColor=gray;这是普通的文本这是一个超链接Document对象对象属性对象对象属性Froms数组数组Anchors数组数组/nameidjihealinks数组数组/hrefjiheaimages数组数组scripts数组数组applets数组数组all数组数组styleSheets数组数组Body对象对象Title对象对象functioncheckall()varowin=window.open(,_blank);owin.document.write(+all数组中一共有+document.all.length+个元素);for(vari=0;idocument.all.length;i+)owin.document.write(+document.alli.tagName+);owin.document.writeln();owin.document.close();top1top2paragraph1paragraph2functioncheckall()varowin=window.open(,_blank);owin.document.write(+all数组中一共有+document.all.length+个元素);for(vari=0;idocument.all.length;i+)owin.document.write(+document.alli.tagName+);owin.document.writeln();varobjnames=links,forms,anchors,scripts,images;for(varj=0;jobjnames.length;j+)owin.document.write(+);eval(owin.document.write(objnamesj+数组中一共有+document.+objnamesj+.length);owin.document.write(个元素);varlen=0;eval(len=document.+objnamesj+.length);for(vari=0;ilen;i+)eval(owin.document.write(+document.+objnamesj+i.name+);owin.document.writeln();/*owin.document.write(document.all7.src);owin.document.write(document.all.img1.src);owin.document.write(document.allimg1.src);owin.document.write(document.all.item(img1).src);owin.document.write(document.all.item(7).src);owin.document.write(document.images0.src);owin.document.write(document.images.img1.src);owin.document.write(document.imagesimg1.src);owin.document.write(document.images.item(img1).src);owin.document.write(document.images.item(0).src);*/owin.document.close();top1top2paragraph1paragraph2functioncheckall()varowin=window.open(,_blank);owin.document.write(document.imagesimg1.src+);owin.document.write(document.images.item(img2).src+);varobjImg=document.images.item(sample)

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

当前位置:首页 > 高中教育 > 初中教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1