摘要:
清华大学出版的《事半功倍系列 javascript》,本人照着书敲出来的,有些翻译了一下.前几年看了一下,最近无事,重新翻了翻,很有帮助.本书应该有光盘的,但学校的书,光盘不知在哪.希望对你学 javascript有帮助关键字:
Javascript学习 js 正文:
第八章 使用窗口
1.在浏览器的状态栏上显示文本
<body onload=window.status="欢迎光临我的站点">
<a href=http://www.sohu.com>sohu</a>
</body>
2.改变背景色
<script>
document.bgColor="orange"
</script>
3.列举背景颜色
<body bgColor =green>
<script>
document.write("当前背景色是:"+document.bgColor)
</script>
</body>
4.改变文本和链接颜色
<script>
document.bgColor="orange"
document.fgColor="blue"
document.linkColor="red"
</script>
<h2>看看这段文本颜色</h2>
<a href=http://www.sohu.com>sohu</a>
</body>
5.改变文档标题
<script>
name="Mouse"
document.title="welcome to "+name+"'s House"
document.write(document.title)
</script>
6.显示修改日期
<script>
document.write("本页面最后修改时间是"+document.lastModified)
</script>
7.查看当前文档的URL
<script>
document.write("本页面的URL:"+document.URL)
</script>
8.查看引用页
<script>
document.write("本页面的引用页是"+document.referrer)
</script>
9.打开新的浏览器窗口
<script>
window.open("*.htm","title","width=200,height=400,resizable=yes")
</script>
10.关闭远程窗口
close.html:
<script>
document.write("正文")
</script>
<form name=form1>
<input type=button name=button1value="关闭" onclick=window.close()>
</form>
open.html
<script>
window.open("close.html","romote","width=200,height=400,resizable=yes")
</script>
11.打印窗口
<script>
document.write("正文")
</script>
<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.改变窗口大小
<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)>
[1][2][3][4][5][6][7][8]