窗口對象的屬性和方法:
格式:
[window.]屬性
[window.]方法(參數)
opener.屬性
opener.方法(參數)
self.屬性
self.方法(參數)
parent.屬性
parent.方法(參數)
top.屬性
top.方法(參數)
窗口名稱.屬性
窗口名稱.方法(參數)
窗口對象的事件處理程序:
onBlur onDragDrop onError onFocus onLoad onMove onResize onUnload
- <Script>
- function checkPassword(testObject) {
- if (testObject.value.length < 6) {
- alert("密碼長度不得小於6");
- testObject.focus();
- testObject.select();
- }
- }
- </Script>
- 請輸入密碼:
- <INPUT TYPE="text" onBlur="checkPassword(this)">
<Script>
function checkPassword(testObject) {
if (testObject.value.length < 6) {
alert("密碼長度不得小於6");
testObject.focus();
testObject.select();
}
}
</Script>
請輸入密碼:
<INPUT TYPE="text" onBlur="checkPassword(this)">
- <Script>
- if (confirm("你滿十八歲了嗎?"))
- location = "adult.htm";
- else
- alert("等你成年以後再來吧!");
- </Script>
<Script>
if (confirm("你滿十八歲了嗎?"))
location = "adult.htm";
else
alert("等你成年以後再來吧!");
</Script>
這個可能被攔截
- <Script>
- var bgColor =
- prompt("你喜歡哪一種底色:/n淺藍色請按1,粉紅色請按2",1)
- if (bgColor == 1) document.bgColor = "#CCFFFF";
- else if (bgColor == 2) document.bgColor = "#FFCCFF";
- else document.bgColor = "#FFFFFF";
- </Script>