事半功倍之js(三)
时间:2008-04-22 来源:傲枭
6.引用当前对象
<form name=form1>
<input type=text name=text1 value="dgdgdfgfd" onclick=this.select()>
</script>
7.查看对象属性
8.使用Array对象
9.使用 image 对象
<img src=**.gif alt="图片提示…." border=10>
10.预加载图像
<body onload=document.images[0].src=freddy.src>
,<img src="blank.gif">
</body>
11.改变图像
<img src=freddy.gif><br>
<form name=form1>
<input type=button name=button1 value="改变图像" onclickd=document.images[0].src=dudjp.gif>
</form>
12.使用link和anchor对象
<a name=anchor1>锚点1<br>
<a href=http://www.microsoft.com>Microsoft</a><br>
<a href=http://www.sohu.com>sohu</a><br>
<a href=http://www.sina.com.cn>sina</a><br>
13.改变链接
<a href =http://www.microsoft.com>link</a>
<form name=form1>
<input type=button name=button1 value="改变链接" onclick=document.links[0].href='http://www.sohu.com'>
</form>
14.使用history对象
<form name=form1>
<input type=button name=button1 value="向后返回2页" onclick=window.history.go(-2)>
</form>
<form name=form1>
<input type=text name=text1 value=hello>
</form>
<form name=form1>
<input type=radio name=radio1>男
<input type=radio name=radio2>女
</script>
第八章 使用窗口
1.在浏览器的状态栏上显示文本
<body onload=window.status="欢迎光临我的站点">
<a href=http://www.sohu.com>sohu</a>
</body>
2.改变背景色
3.列举背景颜色
<body bgColor =green>
</body>
4.改变文本和链接颜色
<h2>看看这段文本颜色</h2>
<a href=http://www.sohu.com>sohu</a>
</body>
5.改变文档标题
6.显示修改日期
7.查看当前文档的URL
8.查看引用页
9.打开新的浏览器窗口
10.关闭远程窗口
11.打印窗口
<form name=form1>
<input type=button value=打印 onclick=window.print()>
</form>
12.移动窗口
<form name=form1>
水平方向<input type=text name=x value=20>
垂直方向<input type=text name=y value=50>
<input type=button value="移动窗口到…"onclick=window.moveTo(document.form1.x.value,document.form1.y.value)>
</form>
<form name=form1>
水平方向<input type=text name=x value=20>
垂直方向<input type=text name=y value=50>
<input type=button value="移动窗口"onclick=window.moveBy(document.form1.x.value,document.form1.y.value)>
</form>
13.改变窗口大小
14.用警告对话框通知用户
15.用提示对话框接受输入
16.用确认对话框使用户做出决定
<form name=form1>
水平方向<input type=text name=x value=200>
垂直方向<input type=text name=y value=500>
<input type=button value="改变窗口大小到….."onclick=window.resizeTo(document.form1.x.value,document.form1.y.value)>
</form>
<form name=form1>
水平方向<input type=text name=x value=200>
垂直方向<input type=text name=y value=500>
<input type=button value="改变窗口大小"onclick=window.resizeBy(document.form1.x.value,document.form1.y.value)>
</form>
close.html:
<form name=form1>
<input type=button name=button1value="关闭" onclick=window.close()>
</form>