window.open()方法以及系统弹出框alert等

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <title>javascript之正则表达式</title>
</head>
<body>
<h1>笔记</h1>
<input type="button" id="b1" value="button"/>
<script>
    var B1 = document.getElementById("b1");
    B1.onclick = function(){
        // window.open("domo1.html","top","width=400,height=400,top=100,left=100,resizable=no");  //first
        // window.open("domo1.html","_self","width=400,height=400,top=100,left=100,resizable=no");  //second
        window.open("domo1.html","top");  //third
    }

    //第二个参数可以是_self  _parent  _top   _blank 或者其他的框架名称,甚至还可以是不存在的窗口或框架
    //第三个参数是为了第二个参数为不存在的窗口名或框架名之后,用于设定一个新框架页面的大小等特性,使用都好分
    //隔的名值对字符串;如果第三个参数没有设定,则是浏览器页面默认大小,包括地址栏等
    //window.open()方法打开的窗口可以通过window.close()关闭,而其他方法打开的窗口则不可以
</script>
</body>
</html>
window.open("domo1.html","top","width=400,height=400,top=100,left=100,resizable=no");  //first

first下的情况

window.open("domo1.html","_self","width=400,height=400,top=100,left=100,resizable=no");  //second

second下的情况

window.open("domo1.html","top");  //third

third下的情况

    //系统弹出框alert() confirm() prompt()
    alert("this is alert");
    var c = confirm("this is confirm");
    //如果点击了confirm弹出框的确定按钮,返回一个true,否则false
    //该特性可以用于处理不同的事件
    if(c){
        console.log("你选择了确定");
    }else{
        console.log("你选择了取消");
    }
    var p = prompt("this is prompt?","输入名字");
    console.log("你输入的名字是:"+p);
</script>

下图是各个实例的图以及执行相关操作后的结果展示
alert
alert

confirm

prompt

prompt1

console

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值