1、 resizable: 是否允许改变窗口大小,yes或1为允许 location: 是否显示地址栏,yes或1为允许 status:是否显示状态栏内的信息,yes或1为允许定时器 轮询 Window. setTimeout(函数名,指定时间毫秒数) 延时执行某个函数 执行一次 clearTimeout(定时器对象名称) 取消执行定时器 setInterval(函数名称,时间毫秒数) 定时执行指定的函数 间隔为多少毫秒数 clearInterval (定时器对象名称) 取消定时器定时器示例: /setTimeout(函数名,指定时间毫秒数) 延时执行某个函数 执行一次 /clearTimeout
2、(定时器对象名称) var start; function showName() document.allmyname.style.display=block; start=setTimeout(hideName(),300); function hideName()noneshowName() function stopTime() if (start != null) clearTimeout(start); start=null; document.all.btn.value=开始闪烁 else start = setTimeout(, 300);停止闪烁/script/headbody
3、 onLoad=showName(); h2Hellofont id= color=red style=display:肖总/h2/body /setInterval(函数名称,时间毫秒数) 定时执行指定的函数 间隔为多少毫秒数 /clearInterval (定时器名称) 取消定时器 var num=0; var myTimer; function show() document.all.myNum.innerHTML=num+; function testTimer() if(myTimer!=null ) clearInterval(myTimer); num=0; myTimer=nu
4、ll;开始计时 else myTimer=setInterval(show,100);停止计时body计时:myNum face=宋体 0其他例子见:js_时间显示器.html js_跑马灯.html js_文字滚动.html网页对话框 模式对话框和无模式对话框 window.showModalDialog(,传递变量名,窗口特征) 建议传递window对象 window.showModelessDialog() 子窗口访问父窗口数据使用 dialogArguments对象 返回到父窗口的值使用 returnValuewindow对象的子对象属性:parent对象 代表对象层次中的父窗口 pa
5、rent对象仅仅是对子窗口有意义self 对象 代表对当前窗口或框架的引用 top 对象 代表最顶层的窗口opener对象 代表创建当前窗口的源窗口 用于确定open方法打开窗口的源窗口location 对象 代表特定窗口的URL信息 location.replace(url) 刷新 不后退 location.href= 加载 可后退 window.location.reload();history对象 用于存储客户端最近访问过的网址清单javascript:top.mymain.history.forward(); =history.go(1)top.mymain.history.back(
6、1); =history.go(-1) history.go() 刷新 表单不提交 history.forward() 指向浏览器历史列表中的下一个URL, 相当于点击浏览器的“前进”按钮 history.back() 指向浏览器历史列表中的上一个URL, 相当于点击浏览器的“后退”按钮window.screen 代表浏览器屏幕 设置浏览器屏幕 var h=screen.Height; /屏幕高度 var w=screen.Width; /屏幕宽度window对象属性:window.status 代表浏览器状态栏 设置状态栏标题 window.status=清华ITwindow.closed
7、窗口是否关闭window的事件htmlhead window 对象的专有事件演示script language=javascript type= alert(开始加载网页.n -请注意网页的加载顺序-!- window的专有事件: onload 在浏览器完成对象的装载后触发事件 onunload 在对象卸载前立即触发事件 onbeforeunload 在页面将要被卸载前触发事件 window对象的事件处理通过body标签的事件属性来设置的 -body onload=alert(html文档加载完毕) onbeforeunload=window.event.returnValue=*你确定关闭本
8、窗口* onunload=拜拜注意网页的加载顺序哦!加载写在最下面的JavaScript脚本 document对象 代表给浏览器窗口中的 HTML 文档 document的属性: language=JavaScript function change() document.bgColor=green document.fgColor= /文本前景色 document.vlinkColor=0x00ff00 /已访问过的链接文本颜色 document.linkColor=gray /链接文本颜色 function showURL() alert(document.URL); /当前文档Unico
9、de编码的 URL地址 change();普通文本a href=#showURL();链接 document的方法 document.write()document.writeln() document.close()开始的内容 document.write(这是document对象写入的内容 var str = world哈楼 , str, javascript , document.writeln(mystr = Hello World document.writeln(mystr) var a = 帅哥 document.write(newStr = (a = 美女) ? 东方不败 :西
10、门吹雪 document.write( function changeDoc() document.writeln(以下是更新后的文档内容/注意这里写法测试document对象changeDoc(); document.close(); /关闭文档 输出 document集合属性: document.forms /返回文档中的表单数组 document.anchors /获取所有带有 name 和/或 id 属性的 a 对象的集合数组 document.images /返回文档中的image的数组 document.links /获取文档中所有指定了 HREF 属性的 a 对象和所有 area
11、 对象的集合数组 document.all 返回对象所包含的元素集合的引用 window.status = /设置状态栏文本 document.title = 演示 alert(文档标题: + document.title);所有指定了href属性的 对象集合数组长度: + document.links.length);所有带有 name或 id 属性的 a对象的集合数组长度: + document.anchors.length); alert(document.links1.href); alert(document.allan1.name) alert(document.formsfrm1
12、.method);button name=show(); document集合属性演示/buttonbr/a name=a TO js_right.htmlan2b href=js_left.html链接到js_left.htmljs_right.html链接到js_right.htmlfrm2postfrm3frames 框架对象 不能同时设定body parent.frames 返回父窗口的框架数组: alert(top.frames.length); alert(parent.frames0.name) alert(parent.framesmyleftbody对象及通用属性body对象
13、方法: function createA() var myA=document.createElement( /创建一个html元素 myA.href=js_跑马灯.html myA.innerText=链接到js_跑马灯.html document.body.appendChild(myA); /body对象添加子节点createA();这是一个javascript动态创建的超链接通用属性:body对象属性演示 body font-size:20px;/style通用属性: innerText 起始和结束标签内的文本 innerHTML 起始和结束标签内的 HTML outerText 起始
14、和结束标签内的文本(包含标签本身) outerHTML 起始和结束标签内的 HTML(包含标签本身) -p id=p1 onmouseover=this.innerText=IinnerText onmouseout=this.innerHTML=innerHTMLdiv onmouseover=p2.outerHTML=p id=p2outerHTML onmouseout=p2.outerText= outerText 测试outerText与outerHTML区别 p2 outerText与outerHTML区别 p id=p3哈楼!innerTextalert(p3.innerText
15、)innerHTMLalert(p3.innerHTML)outerTextalert(p3.outerText)outerHTMLalert(p3.outerHTML)div id=float_iconposition:absolute;left=0;top=0;img src=cat.gif border=1script /* offsetTop 表示对象距顶部高度 offsetLeft 表示对象距左边宽度 offsetWidth 表示对象宽度 offsetHeight 表示对象高度 clientWidth 表示对象不包含滚动条或边框、边距的宽度 clientHeight 表示对象不包含滚
16、动条或边框、边距的高度 clientTop 表示对象不包含滚动条或边框、边距的距父容器顶部高度 clientWidth 表示对象不包含滚动条或边框、边距的距父容器左边宽度 */ var dirX = 1, dirY = 1; var xPos = 0, yPos = 0; window.setInterval(moveIcon, 10); function moveIcon() xPos += 2 * dirX; yPos += 2 * dirY; float_icon.style.top = yPos; /top div距顶部高度 float_icon.style.left = xPos;
17、/left div距左边宽度 if (xPos = document.body.clientWidth) dirX = -dirX; if (yPos = document.body.clientHeight) dirY = -dirY;Style对象: function showItem() /获取id为sp的span标记下的img标记数组 var imgs=document.getElementById(sp).getElementsByTagName(img var cp=document.getElementById(cp var canExpand=true; if(imgs0.src.indexOf(minus.gif)!=-1) canExpand=false; imgs0.src=images/plus.gif elseimages/minus.gif if(canExpand) cp.style.display= /显示 /隐藏span id=cursor:hand;showItem()
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1