標籤:ntb image date append 之間 body jpg 指標 created
對象屬性:
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.write() //動態向頁面寫入內容
document.createElement(Tag) //建立一個html標籤對象
document.getElementById(ID) //獲得指定ID值的對象
document.getElementsByName(Name) //獲得指定Name值的對象
document.body.appendChild(oTag)
========================================================================
body-主體子物件
document.body //指定文檔主體的開始和結束等價於<body></body>
document.body.bgColor //設定或擷取對象後面的背景顏色
document.body.link //未點擊過的連結顏色
document.body.alink //啟用連結(焦點在此連結上)的顏色
document.body.vlink //已點擊過的連結顏色
document.body.text //文本色
document.body.innerText //設定<body>...</body>之間的文本
document.body.innerHTML //設定<body>...</body>之間的HTML代碼
document.body.topMargin //頁面上邊距
document.body.leftMargin //頁面左邊距
document.body.rightMargin //頁面右邊距
document.body.bottomMargin //頁面下邊距
document.body.background //背景圖片
document.body.appendChild(oTag) //動態產生一個HTML對象
----------------------------
常用對象事件:
document.body.onclick="func()" //滑鼠指標單擊對象是觸發
document.body.onmouseover="func()" //滑鼠指標移到對象時觸發
document.body.onmouseout="func()" //滑鼠指標移出對象時觸發
========================================================================
location-位置子物件:
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 // ?號後的部分
----------------------------
常用對象事件:
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)通過name屬性直接引用
<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>標籤與之對應就可以顯示
forms集合(頁面中的表單):
----------------------------
a)通過集合引用
document.forms //對應頁面上的<form>標籤
document.forms.length //對應頁面上<form>標籤的個數
document.forms[0] //第1個<form>標籤
document.forms[i] //第i-1個<form>標籤
document.forms[i].length //第i-1個<form>中的控制項數
document.forms[i].elements[j] //第i-1個<form>中第j-1個控制項
----------------------------
b)通過標籤name屬性直接引用
<form name="Myform"><input name="myctrl"></form>
document.Myform.myctrl //document.表單名.控制項名
----------------------------
c)訪問表單的屬性
document.forms[i].name //對應<form name>屬性
document.forms[i].action //對應<form action>屬性
document.forms[i].encoding //對應<form enctype>屬性
document.forms[i].target //對應<form target>屬性
document.forms[i].appendChild(oTag) //動態插入一個控制項
關於document.write(來自網路)