第八章 使用窗口
1.在浏览器的状态栏上显示文本
<body οnlοad=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.关闭远程窗口
11.打印窗口
<script>
document.write("正文")
</script>
<form name=form1>
<input type=button value=打印 οnclick=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="移动窗口到…"οnclick=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="移动窗口"οnclick=window.moveBy(document.form1.x.value,document.form1.y.value)>
</form>
13.改变窗口大小
14.用警告对话框通知用户
<script>
window.alert("welcome")
</script>
15.用提示对话框接受输入
<script>
name=window.prompt("输入姓名","姓名")
document.write(" 欢迎您:"+name+"来到这里")
</script>
16.用确认对话框使用户做出决定
<script>
like=window.confirm("你觉得好吗?")
if(like==true)
document.write("谢谢你的夸奖")
else
document.write("希望得到你的夸奖")
</script>
<form name=form1>
水平方向<input type=text name=x value=200>
垂直方向<input type=text name=y value=500>
<input type=button value="改变窗口大小到….."οnclick=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="改变窗口大小"οnclick=window.resizeBy(document.form1.x.value,document.form1.y.value)>
</form>
close.html:
<script>
document.write("正文")
</script>
<form name=form1>
<input type=button name=button1value="关闭" οnclick=window.close()>
</form>
open.html
<script>
window.open("close.html","romote","width=200,height=400,resizable=yes")
</script>