1.代碼寫在scipt標簽內。
</script>
2.定義數組
var myarray=new Array();
3.各種事件
各種事件
4.事件與文本框:
密碼:<input name="password" type="text" value=http://www.ithao123.cn/"請輸入密碼!" onblur="message()">
寫在body的form內。
5.事件與文本框2:類似textView
<form>
個人簡介:<br>
<textarea name="summary" cols="60" rows="5" onselect="message()">請寫入個人簡介,不少於200字!</textarea>
</form>
6.onload事件在頁面加載完成後立即發生,事件寫在body標簽內。
<body onload="message()">
歡迎學習JavaScript。
</body>
7.卸載事件(onunload)
當用戶退出頁面(頁面關閉或刷新時),觸發onunload事件。
註意:不同瀏覽器對onunload事件支持不同。
<script type="text/javascript">
window.onunload = onunload_message;
function onunload_message(){
alert("您確定離開該網頁嗎?");
}
</script>
註意寫法的區別。
8.獲取元素的方法
獲取和修改值都使用該方法.
document.getElementById("id") .value = http://www.ithao123.cn/value
9.使用parseInt()可獲取該元素的整數值.
Tags:
文章來源: