一。open()打开close()关闭
window.open("https://www.mi.com/index.html") //1个参数的时候,每次刷新页面都是打开新的窗口
window.open("https://www.mi.com/index.html","小米") // 2个参数,每次刷新页面都是刷新的第一次打开的窗口
window.open("https://www.mi.com/index.html","小米","网页的设置") // 可以对打开的新窗口进行设置
二。
定时器
定义多少秒之后执行,时间(单位为毫秒,1000=1000毫秒=1s)
setTimeout(函数,时间)
setTimeout( function fn(){
window.open('https://www.mi.com/index.html' )
},3000)间隔3秒打开网页
定义间隔多少秒重复执行
setInterval(函数,时间)
let time = setInterval(function() {
window.open("https://www.mi.com/?masid=2701.0313");
},2000)
// 关闭标签页
// setTimeout(function(){
// clearInterval(time);
// },2000)
setTimeout(function() {
window.close(time);
},10000),会关闭原网页