1. 程式人生 > >js_提示是否刪除小案例

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>