<!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

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

window.open("domo1.html","top"); //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





本文介绍了JavaScript中window对象的方法,包括使用window.open()打开新窗口的不同方式及其参数设置,以及如何利用alert(), confirm()和prompt()实现不同类型的系统对话框。
4159

被折叠的 条评论
为什么被折叠?



