Window对象
//确认弹出框
confirm("您确定是否删除吗?");
//输入框
prompt("请输入价格");
History对象
<html>
<head>
<meta charset="UTF-8">
<title>History对象</title>
<script>
function fanhui(){
history.go(-1);
//history.back();
//history.forward();
}
</script>
</head>
<body>
<input type="button" value="返回上一页" onclick="fanhui()"/><br />
<a href="03_Location对象.html">下一页</a>
</body>
</html>
Location对象
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Location对象</title>
</head>
<body>
<input type="button" value="跳转到history页面" onclick="javascript:location.href='02_History对象.html'"/>
</body>
</html>
聚焦事件onfocus(昂for k 斯)
<script>
function showTips(id,info){
document.getElementById(id+"span").innerHTML="<font color='gray'>"+info+"</font>";
}
function check(id,info){
//1.获取用户输入的用户名数据
var uValue = document.getElementById(id).value;
//2.进行校验
if(uValue==""){
document.getElementById(id+"span").innerHTML="<font color='red'>"+info+"</font>";
}else{
document.getElementById(id+"span").innerHTML="";
}
}
</script>
<body>
<input type="text" name="user" size="34px" id="user" onfocus="showTips('user','用户名必填!')" onblur="check('user',' 用户名不能为空!')"/><span id="userspan"></span>
</body>
网友评论