Dom之事件
下面的代码实现了onload,onbeforeunload,onunload三个常用事件和一些常用属性:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body onload="btn.value='ok'" onbeforeunload="window.event.returnValue='确实要离开吗?'" onunload="alert('再见!')">
<input type="button" id="btn" value="按钮" />
<input type="button" value="href" onclick="alert(location.href);" />
<input type="button" value="重定向" onclick="location.href = 'HtmlPage走马灯.html';" />
<input type="button" value="点击" onclick="if (window.event.ctrlKey) { alert('按下了ctrl点击的'); }
else { alert('正常点击'); }" />
<a href="http://www.baidu.com" onclick="alert('禁止访问');">百度</a>
<form action="1.ashx">
<input type="submit" value="提交" onclick="alert('数据出错'); window.event.returnValue = false;" />
</form>
</body>
</html>