第一章:
<script language="JavaScript">
document.write("abianbitch");
</script>
第二章:
<script>
document.write("網站 : " + document.URL +
"<br>");
document.write("最後編輯 :" + document.lastModified
+ "<br>"); //最後編輯
document.write("標題,或文章標題: " + document.title
+ "<br>");
document.write("文字 " + document.bgColor
+ " 背景顏色 " + document.fgColor);
document.fgColor = "yellow";
document.bgColor = "black";
</script>
第三章:
var array_name = new Array() ;
var array_name = new Array(100) ; //數字為定義量
var array_name = new Array(data1 , data2 , data3 , ... , dataN) ; //字串為定義字串內容
array_name[index]
array_name.length //有多少陣列數
var可以做為形式宣告。
week_array.length =100
第四章:
a = 00001100b = 12
a << 2 = 00110000b = 48
c
= 負 (2 的 30 次方)
= -1073741824
c >>> 2
= 805306368
= 2 的 29 次方 + 2 的 28 次方
例子:用 << 做乘以 2 的倍數運算, 用 >> 做除以 2 的倍數運算。
第六章:
<script>
function bt_details(this_bt) {
var name = this_bt.name
var value = this_bt.value
var type = this_bt.type
document.write("My name is <b>" + name + "</b>");
document.write("<br>My value is <b>" + value +
"</b>");
document.write("<br>My type is <b>" + type +
"</b>");
}
</script>
<form>
<input type="button" name="hello"
value="Please Click me to see my name and value"
onClick="bt_details(this)">
</form>
onBlur 使用者離開某一欄
onChange 使用者改變某一欄的內容
onClick 使用者按下某個按鈕
onFocus 使用者的輸入焦點進入某一欄
onLoad 某一頁完全載入
onMouseOver 滑鼠游標在某個物件之上
onMouseOut 滑鼠游標離開某個物件
onSelect 使用者選擇某一欄的內容
onSubmit 使用者確定送出某表單
onUnload 正在顯示的一頁被改變
中階
第一章:
警告。
<form>
<input type="button" value="Pop-up an alert box" onClick="alert('Hi, I am alert box.')">
</form>
<form>
<input type="button" value="Pop-up an confirm box"
onClick="var reply = confirm('Are
you sure?') ; alert(reply)">
</form>
<form>
<input type="button" value="Ask me a question"
onClick=" var name = prompt('What
is your name?.' , 'You name
here') ; alert('Hi, ' + name) ">
</form>
載入視窗
var winvar = window.open("http://www.yahoo.com","winname",
"location,menubar=1 status,toolbar,scrollbars=0");
關閉視窗
<input type="button" value="Close the pop-up window" onClick="winvar.close()">
時間彈跳式窗
setTimeout("alert('5 seconds has passed')" , 5000);
偵測變數:
只須在變數名稱之前加上 window 一字, 再用 if 敘述, 就可以知道該變數是否存在,
沒有留言:
張貼留言