都是网页中的JavaScript对象。
新建 html 文件 20-window.html
,编写下方程序,运行看看效果吧
<!DOCTYPE html>
<htmllang="en">
<head>
<metacharset="UTF-8">
<metahttp-equiv="X-UA-Compatible"content="IE=edge">
<metaname="viewport"content="width=device-width, initial-scale=1.0">
<title>Window</title>
</head>
<body>
<ahref="./19-alert.html">19-alert</a>
<buttononclick="nav()">跳转</button>
<inputid="myname"/>
<buttononclick="getMyName()">获取内容</button>
<divid="mylight"style="width:50px;height:50px;background-color: black;">灯</div>
<buttononclick="openLight()">开灯</button>
<scripttype="text/javascript">
//alert(window.innerWidth)
//alert(window.innerHeight)
function nav(){
window.location.href ="./19-alert.html"
// window.location.reload();//页面刷新
}
function getMyName(){
let myname = document.getElementById("myname").value
alert(myname)
}
function openLight(){
document.getElementById("mylight").style.backgroundColor="red"
}
</script>
</body>
</html>
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有