当前位置:网站首页>DOM案例:10秒倒计时-写跳转页面相关的知识
DOM案例:10秒倒计时-写跳转页面相关的知识
2022-07-26 18:26:00 【前端小草籽】
1.弹窗(有点类似于 alert )
window.confirm()方法显示一个具有一个可选消息和两个按钮 (确定和取消) 的模态对话框 。
因为是window方法,不写window ,只写 confirm也可以 出现的弹框,点击确定就返回true,取消就返回false
语法:
result = window.confirm(message);
- message 是要在对话框中显示的可选字符串。
- result 是一个布尔值,表示是选择确定还是取消 (true 表示 OK)。
<body>
<style>
*{margin: 0;padding: 0;}
/* 设置外部的大盒子样式 */
.box{
width: 200px;
height: 300px;
background-color: rgb(238, 238, 238);
/* 居中 */
margin: 100px auto;
}
/* 设置每一项的样式 */
li{
/* 清除小圆点 */
list-style: none;
/* 设置内边距 上下为10px,左右为10px*/
padding: 10px 10px;
}
/* 设置按钮那一项的样式 */
#btn{
/* 设置弹性布局,里面的元素为弹性子元素 */
display:flex;
/* 距离li部分的距离 */
margin-top: 30px;
/* 设置弹性子元素的排布 */
/* 每个项目两侧的间隔相等 */
justify-content: space-around;
}
</style>
<div class="box">
<ul>
<li>商品:Web前端课程</li>
<li>原价:1980元</li>
<li>现价:1.98元</li>
<li>内容:HTML,CSS,JS</li>
<li>地址:重庆市垫江县</li>
</ul>
<div id="btn">
<button id="btn1">取消</button>
<button id="btn2">支付</button>
</div>
</div>
<script>
//业务需求,一点击支付按钮,弹出“谢谢你的选择”,页面跳转到支付成功的页面
//给支付按钮绑定点击事件
let zF = document.querySelector('#btn2');
zF.onclick = function(){
let res = window.confirm('你确定要支付么?');
if(res){
console.log('点击了确定,返回true');
}else{
console.log('点击了取消,返回了false');
}
}
</script>
</body>
上面这个图就是 window.firm的效果图。
2.window.location 只读属性,返回一个 Location 对象,
Locattion对象的属性 href 从当前页面跳转到 href属性所指的页面
window.location.href = 'https://www.baidu.com'
3.window.onload 事件
该事件在文档上载过程结束时触发该事件。此时,文档中的所有对象都是 DOM,并且所有图像和子帧都已完成加载
边栏推荐
- The difference between advanced anti DDoS server and advanced anti DDoS IP
- 调整数组顺序使奇数位于偶数前面且相对位置不变
- SEO, client rendering ', server rendering, search engine understanding
- ReentrantLock学习之公平锁过程
- All you want to know about interface testing is here
- Leetcode notes: biweekly contest 83
- The passwords are consistent, and the total display is as shown in the figure below
- Conda+pytorch environment tutorial
- PyQt5快速开发与实战 3.6 打包资源文件
- Volatile keyword of JVM memory model
猜你喜欢

Vs2019 export import configuration

Usage scenarios for automated testing

To add a composite primary key

测试面试题集-UI自动化测试

J3:Redis主从复制

Redis6

Some time series modeling strategies (I)

Data Lake -- concept, characteristics, architecture and case overview

工作13年后,个人的一点软件测试经历及感想……

A case study of building an efficient management system for a thousand person food manufacturing enterprise with low code
随机推荐
服务发现原理分析与源码解读
什么是联邦图机器学习?弗吉尼亚大学最新《联邦图机器学习:概念、技术和应用》综述
什么是服务器集群?海外服务器集群的优势?
用低代码搭建千人食品制造企业高效管理系统案例分析
MySQL教程:MySQL数据库学习宝典(从入门到精通)
Mongodb stats counts the space occupied by the collection
C # create and read dat file cases
Some time series modeling strategies (I)
Leetcode notes: biweekly contest 83
The inventory of chips in the United States is high, and the shipment of chips in China has increased rapidly and the import of 28.3 billion chips has been greatly reduced. TSMC has a showdown
SEO、客户端渲染‘、服务端渲染、搜索引擎的理解
UIAutomator2常用类之UiObject2
线性代数第4章线性方程组
如果密钥忘记,多个设备分别不同的密钥,云端是如何同步
What do indicators and labels do
时空预测4-graph wavenet
PADS画2.54mm排针
Without Lin benjian, there would be no TSMC today!
C language - Introduction - syntax - string (11)
conda转移项目虚拟环境必备技能+pip速度下载太慢解决办法