<input type="password" onblur="checkPassword(this)"> <script > function checkPassword(object) { if (object.value.length <= 4) { alert("密码长度过短"); object.focus(); object.select(); } } </script>
<script > if (confirm("你想退出吗")) { window.location.href = "http://www.baidu.com"; } else { alert("hi"); } </script><script > with(document) { write("屏幕设定值<br>"); write("实际高度:",screen.availHeight,"<br>"); write("实际宽度:",screen.availWidth,"<br>"); write("屏幕区域高度:",screen.height,"<br>"); write("屏幕区域宽度:",screen.width,"<br>"); } </script><script > // event参数是系统生成并传递过来的 function getEvent(event) { alert("事件类型:" + event.type); } document.write("单击..."); document.onmousedown = getEvent; </script><input type="button" value="click" id="button1"> <script > var v = document.getElementById("button1"); v.onclick = clickHandler; function clickHandler(event) { alert(event.type); } </script><input type="button" value="click" id="button1"> <script > var v = document.getElementById("button1"); v.onclick = clickHandler; function clickHandler() { alert("I am a button!"); } </script>