第 5 页 事半功倍之Javascript [5]

第八章 使用窗口

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> 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值