<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Hopes

    Start Here..

     

    javaScript document對象詳解

    javaScript document對象詳解

    來源:web開發    發布日期:2009-6-10    閱讀數: 32720

    Document對象內容集合

    document 文擋對象 - JavaScript腳本語言描述
    ———————————————————————
    注:頁面上元素name屬性和JavaScript引用的名稱必須一致包括大小寫
    否則會提示你一個錯誤信息 “引用的元素為空或者不是對象\\\\\”
    ———————————————————————

    對象屬性
    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)通過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 /標簽與之對應就可以顯示

    ———————————————————————-

    forms集合(頁面中的表單)

    a)通過集合引用
    document.forms //對應頁面上的form標簽
    document.forms.length //對應頁面上/formform標簽的個數
    document.forms[0] //第1個/formform標簽
    document.forms[i] //第i-1個/formform標簽
    document.forms[i].length //第i-1個/formform中的控件數
    document.forms[i].elements[j] //第i-1個/formform中第j-1個控件

    b)通過標簽name屬性直接引用
    /formform name=”Myform”>input name=”myctrl”/>/form
    document.Myform.myctrl //document.表單名.控件名

    c)訪問表單的屬性
    document.forms[i].name //對應form name>屬性
    document.forms[i].action //對應/formform action>屬性
    document.forms[i].encoding //對應/formform enctype>屬性
    document.forms[i].target //對應/formform target>屬性

    document.forms[i].appendChild(oTag) //動態插入一個控件
    document.all.oDiv //引用圖層oDiv
    document.all.oDiv.style.display=” //圖層設置為可視
    document.all.oDiv.style.display=”none” //圖層設置為隱藏
    document.getElementId(”oDiv”) //通過getElementId引用對象
    document.getElementId(”oDiv”).style=”
    document.getElementId(”oDiv”).display=”none”
    /*document.all表示document中所有對象的集合
    只有ie支持此屬性,因此也用來判斷瀏覽器的種類*/

    圖層對象的4個屬性
    document.getElementById(”ID”).innerText //動態輸出文本
    document.getElementById(”ID”).innerHTML //動態輸出HTML
    document.getElementById(”ID”).outerText //同innerText
    document.getElementById(”ID”).outerHTML //同innerHTML

    posted on 2012-05-10 21:06 ** 閱讀(159) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     

    導航

    統計

    公告

    你好!

    常用鏈接

    留言簿(2)

    隨筆檔案

    文章分類

    文章檔案

    新聞檔案

    相冊

    收藏夾

    C#學習

    友情鏈接

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 67194国产精品免费观看| 亚洲欧美日韩久久精品| 青青操免费在线视频| 亚洲AV无码一区二区三区在线观看| 亚洲国产成AV人天堂无码| 色猫咪免费人成网站在线观看| 亚洲av无码一区二区三区乱子伦| 国产三级在线免费观看| 久久亚洲国产成人精品无码区| 成年免费a级毛片| 久久亚洲AV无码西西人体| 波多野结衣免费一区视频| 亚洲成AV人片在| 16女性下面无遮挡免费| 亚洲一区二区三区国产精品无码| 国产免费久久精品99re丫y| 亚洲字幕AV一区二区三区四区| 青青草国产免费久久久下载 | 在线精品免费视频| 亚洲欧美国产精品专区久久| 国产美女无遮挡免费视频网站| 美女露隐私全部免费直播| 三上悠亚亚洲一区高清| 鲁丝片一区二区三区免费| 亚洲国产精品乱码在线观看97| 欧洲乱码伦视频免费| 久久亚洲AV成人无码国产电影| 亚洲性日韩精品一区二区三区 | 久久精品国产亚洲AV无码偷窥| 日本最新免费网站| 亚洲妇女无套内射精| 久久精品国产亚洲Aⅴ香蕉| 久久中文字幕免费视频| 亚洲午夜理论片在线观看| 亚洲VA综合VA国产产VA中| 日韩精品无码专区免费播放| 亚洲午夜福利在线视频| 伊人久久亚洲综合| 西西大胆无码视频免费| 一级毛片免费毛片毛片| 亚洲影视自拍揄拍愉拍|