JS浏览器对象-window对象

本文展示了一个简单的HTML页面示例,其中包括基本的HTML结构、内联CSS样式表链接及JavaScript代码。通过这些代码,页面能够显示问候消息,并且能够响应按钮点击事件,从而打开一个新的窗口。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

代码:

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4 <meta charset="UTF-8">
 5 <title>uvi</title>
 6      <link rel="stylesheet" href="style.css" type="text/css">
 7 </head>
 8 <body>
 9    <button id="btn" onclick="btnClicked()">按钮</button>
10    <script>
11       window.document.write("hello");
12       
13       //获取浏览器的宽度和高度
14       document.write("宽度="+window.innerWidth+",高度="+window.innerHeight);
15       
16       //点击按钮会打开index5.html这个页面
17       function btnClicked(){
18           window.open("index5.html","windowname","height=200,width=200,top=100,left=100,toolbar=no,menubar=no");
19           //3个参数,(url,名称,具体设置)
20       }
21       //window.close();关闭页面
22    </script>
23    
24 </body>
25 </html>

 

转载于:https://www.cnblogs.com/UniqueColor/p/5755814.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值