HTML上document的方法


document:屬性
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:方法
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對象

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        // ?號后的部分

document.location.origin  //url頭

常用對象事件:
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>標簽與之對應就可以顯示

 

轉載:https://blog.csdn.net/ijavaweb/article/details/18555757


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM