DIV CSS 佈局教程網

JavaScript 物件、屬性與事件快速查閱整理
編輯:JavaScript基礎知識     

以下整理 JavaScript 常用物件、屬性與事件,方便開發時快速查閱。

window 物件

window 是瀏覽器中的頂層物件,包含 frames、self、parent、top、status、defaultStatus、name 等屬性,以及 alert、confirm、prompt、open、close 等方法。

location 物件

location 用來取得與操作目前網址,常見屬性有 href、protocol、host、hostname、port、pathname、hash、search。

document 物件

document 代表目前文件,常見屬性有 title、location、lastModified、referrer、bgColor、fgColor、forms、links、anchors。常用方法包括 write、writeln、clear、close。

form 物件

表單物件包含 name、method、action、target、elements、length 等屬性,並可透過 submit 提交表單,或透過 onSubmit 攔截提交行為。

表單元素

text、textarea、checkbox、radio、select、button、password 等元素各有 value、name、checked、selectedIndex 等屬性,也可使用 focus、blur、select、click 等方法。

navigator 與 history

navigator 提供 appName、appVersion、userAgent 等資訊,history 則可用來控制瀏覽歷史,例如 history.go(-1)。

String、Date 與 Math

String 提供 charAt、indexOf、substring、toLowerCase、toUpperCase 等方法。Date 提供 getFullYear、getMonth、getDate、getHours、getTime 等方法。Math 提供 abs、ceil、floor、round、max、min、random、sqrt 等方法。

常見事件

滑鼠事件包括 click、dblclick、mousedown、mouseup、mouseover、mouseout。鍵盤事件包括 keydown、keypress、keyup。表單事件包括 change、submit、reset、select、focus、blur。

事件座標與視窗

event.clientX 與 event.clientY 可取得滑鼠點擊座標,event.offsetX 與 event.offsetY 可取得目前懸停座標。window 還提供 scroll、resizeTo、moveTo、focus、open 等方法。

舊版 IE 的 filter 與 cursor 樣式也常被收錄在速查表中,但現代開發應優先使用標準 CSS 與 DOM API。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved