1.1使用全局作用域
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>全局作用域1</title>
<script type="text/javascript">
var a = "a"; //全局变量a
window.b="window.b";//window对象b
c = "c";//window属性,未声明的对象可以用window对象进行访问
alert(delete window.a);
alert(delete window.b);
alert(delete window.c);
alert(window.a);
alert(window.b);
alert(window.c);
</script>
</head>
<body>
</body>
</html>
1.2系统测试方法
alert():提示对话框
confirm():确认对话框
prompt():输入对话框
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<script type="text/javascript">
var user = prompt("请输入你的用户名:");
if(!!user){//把输入的信息转化为布尔值
var ok = confirm("你输入的用户名名:\n"+user+"\n请确认");
//输入信息确认
if(ok){
alert("欢迎你:\n"+user)
}else{//重新输入信息
user = prompt("请输入你的用户名:");
alert("欢迎你:\n"+user);
}
}else{//提示输入信息
user = prompt("请输入你的用户名:")
}
</script>
<body>
</body>
</html>
1.3、打开和关闭窗口
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<script type="text/javascript">
var url = "http://www.baidu.com/";
var features = "height = 100, width = 1,top = 100, left = 100, toolbar = no, menubar = no, scrollbars = no, resizable = no, location = no, status = no";
document.write('<a href="http://www.baidu.com/" target="newW">切换到百度首页</a>' );
var me = window.open(url,"newW",features);
setTimeout(function(){
me.close();
},3000);
</script>
<body>
</body>
</html>
1.4使用框架集