js中document的用法小結



document常用屬性:

  document.title//設置文檔標題,與HTNL中的title標簽等價

  document.bgColor//設置頁面背景顏色

  document.fgColor//設置頁面前景色

  document.fileCreateDate//文件建立日期,只讀屬性

  document.fileModifiedDate//文件修改日期,只讀屬性

  document.URL//可返回當前文檔的URL

  document.linkColor//未點擊過的鏈接顏色

  doucment.alinkColor//鼠標在此鏈接上的顏色

  document.vlinkColor//已點擊過的鏈接顏色

  document.charset//設置字符集,簡體中文為gb2312

  document.fileSize//文件大小,只讀屬性

  document.cookies//設置和讀出cookie

document的常用方法:

  document.createElement(Tag)//創建HTML元素

  document.getElementById(ID)//獲得指定id值的對象

  document.getElementByName(name)//獲得name值的對象

  document.write()//動態向頁面寫內容

  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.topMargin//頁面上邊距

  document.body.leftMargin //頁面左邊距
  
  document.body.rightMargin //頁面右邊距
  
  document.body.bottomMargin //頁面下邊距

  documenr.body.background//背景圖片

  document.body.appendChild(oTag)//動態生成一個Html對象

常用對象事件:

  document.body.onclick=”func()” //鼠標指針單擊對象是觸發
  
   document.body.onmouseover=”func()” //鼠標指針移到對象時觸發
  document.body.onmouseout=”func()” //鼠標指針移出對象時觸發


免責聲明!

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



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