js_提示是否删除小案例
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
// window.alert('你好吗?');
// alert('aaaa');
// var n;
// n = 10;
// window.n = 11;
// alert();
// window.alert();
//--------------------------------------------------------------------
window.onload = function () {
document.getElementById('btn1').onclick = function () {
if (confirm('您确认要删除吗?')) {
alert('删除成功!');
} else {
alert('取消删除!');
}
};
document.getElementById('btn2').onclick = function () {
// window.navigate('http://www.baidu.com');
// window.location.href = 'http://www.baidu.com';
//location.href = 'http://www.baidu.com';
location = 'http://www.baidu.com';
};
};
//---------------------------------------------------------
</script>
</head>
<body>
<input type="button" name="name" value="删除" id="btn1" />
<input type="button" name="name" value="去百度" id="btn2" />
</body>
</html>