注:頁面上元素name屬性以及JavaScript引用的名稱必須一致包括大小寫
不然會提示你1個錯誤信息 "引用的元素爲空或者不是對象"javascript
1、Window對象
-------------------------------------------------- -------------------
對象屬性
window //窗戶自身
window.self //引用本窗戶window=window.self
window.name //爲窗戶命名
window.defaultStatus //設定窗戶狀態欄信息
window.location //URL地址,配備佈置這個屬性能夠打開新的頁面
-------------------------------------------------- -------------------
對象方法
window.alert("text") //提示信息會話框
window.confirm("text") //確認會話框
window.prompt("text") //要求鍵盤輸入會話框
window.setIntervel("action",time) //每一隔指定的時間(毫秒)就執行一次操做
window.clearInterval() //清除時間配備佈置做用就是終止輪迴
window.setTimeout(action,time) //隔了指定的時間(毫秒)執行一次操做
window.open() //打開新的窗戶
window.close() //關閉窗戶
-------------------------------------------------- -------------------
成員對象
window.event
window.document //見document對象詳解
window.history
window.screen
window.navigator
window.external
-------------------------------------------------- -------------------
window.history對象
window.history.length //瀏覽過的頁面數
history.back() //撤退退卻
history.forward() //進步
history.go(i) //前進或頭退到歷史記錄的第i個頁面
//i>0進步,i<0撤退退卻
-------------------------------------------------- -------------------
window.screen對象
window.screen.width //屏幕寬度
window.screen.height //屏幕高度
window.screen.colorDepth //屏幕色深
window.screen.availWidth //可用寬度
window.screen.availHeight //可用高度(除去任務欄的高度)
-------------------------------------------------- -------------------
window.external對象
window.external.AddFavorite("地址","標題" ) //把網站新增到保藏夾
-------------------------------------------------- -------------------
window.navigator對象
window.navigator.appCodeName //瀏覽器代碼名
window.navigator.appName //瀏覽器步伐名
window.navigator.appMinorVersion //瀏覽器補釘版本
window.navigator.cpuClass //cpu類型 x86
window.navigator.platform //操做體系類型 win32
window.navigator.plugins
window.navigator.opsProfile
window.navigator.userProfile
window.navigator.systemLanguage //客戶體系語言 zh-cn簡體中文
window.navigator.userLanguage //用戶語言,同上
window.navigator.appVersion //瀏覽器版本(包括 體系版本)
window.navigator.userAgent
window.navigator.onLine //用戶否在線
window.navigator.cookieEnabled //瀏覽器是否撐持cookie
window.navigator.mimeTypes
==================================================html
2、document對象java
對象屬性:
document.title //設置文檔標題等價於HTML的<title>標籤
document.bgColor //設置頁面背景色
document.fgColor //設置前景色(文本顏色)
document.linkColor //未點擊過的連接顏色
document.alinkColor //激活連接(焦點在此連接上)的顏色
document.vlinkColor //已點擊過的連接顏色
document.URL //設置URL屬性從而在同一窗口打開另外一網頁
document.fileCreatedDate //文件創建日期,只讀屬性
document.fileModifiedDate //文件修改日期,只讀屬性
document.fileSize //文件大小,只讀屬性
document.cookie //設置和讀出cookie
document.charset //設置字符集 簡體中文:gb2312
----------------------------瀏覽器
document.location.hash // #號後的部分
document.location.host // 域名+端口號
document.location.hostname // 域名
document.location.href // 完整URL
document.location.pathname // 目錄部分
document.location.port // 端口號
document.location.protocol // 網絡協議(http:)
document.location.search // ?號後的部分cookie
documeny.location.reload() //刷新網頁
document.location.reload(URL) //打開新的網頁
document.location.assign(URL) //打開新的網頁
document.location.replace(URL) //打開新的網頁
========================================================================
selection-選區子對象
document.selection
========================================================================
images集合(頁面中的圖象):
----------------------------
a)經過集合引用
document.images //對應頁面上的<img>標籤
document.images.length //對應頁面上<img>標籤的個數
document.images[0] //第1個<img>標籤
document.images[i] //第i-1個<img>標籤
----------------------------
b)經過nane屬性直接引用
<img name="oImage">
document.images.oImage //document.images.name屬性
----------------------------
c)引用圖片的src屬性
document.images.oImage.src //document.images.name屬性.src
----------------------------
d)建立一個圖象
var oImage
oImage = new Image()
document.images.oImage.src="1.jpg"
同時在頁面上創建一個<img>標籤與之對應就能夠顯示
----------------------------
示例代碼(動態建立圖象):
<html>
<img name=oImage>
<script language="javascript">
var oImage
oImage = new Image()
document.images.oImage.src="1.jpg"
</script>
</html>
<html>
<script language="javascript">
oImage=document.caeateElement("IMG")
oImage.src="1.jpg"
網絡