欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

超清晰的document對象詳解

 更新時(shí)間:2007年02月27日 00:00:00   作者:  
document 文擋對象 - JavaScript腳本語言描述
---------------------------------------------------------------------
注:頁面上元素name屬性和JavaScript引用的名稱必須一致包括大小寫
   否則會(huì)提示你一個(gè)錯(cuò)誤信息 "引用的元素為空或者不是對象"
---------------------------------------------------------------------

對象屬性
document.title             //設(shè)置文檔標(biāo)題等價(jià)于HTML的<title>標(biāo)簽
document.bgColor           //設(shè)置頁面背景色
document.fgColor           //設(shè)置前景色(文本顏色)
document.linkColor         //未點(diǎn)擊過的鏈接顏色
document.alinkColor        //激活鏈接(焦點(diǎn)在此鏈接上)的顏色
document.vlinkColor        //已點(diǎn)擊過的鏈接顏色
document.URL               //設(shè)置URL屬性從而在同一窗口打開另一網(wǎng)頁
document.fileCreatedDate   //文件建立日期,只讀屬性
document.fileModifiedDate  //文件修改日期,只讀屬性
document.fileSize          //文件大小,只讀屬性
document.cookie            //設(shè)置和讀出cookie
document.charset           //設(shè)置字符集 簡體中文:gb2312
---------------------------------------------------------------------
對象方法
document.write()                  //動(dòng)態(tài)向頁面寫入內(nèi)容
document.createElement(Tag)       //創(chuàng)建一個(gè)html標(biāo)簽對象
document.getElementById(ID)       //獲得指定ID值的對象
document.getElementsByName(Name)  //獲得指定Name值的對象
---------------------------------------------------------------------

images集合(頁面中的圖象)

a)通過集合引用
document.images             //對應(yīng)頁面上的<img>標(biāo)簽
document.images.length      //對應(yīng)頁面上<img>標(biāo)簽的個(gè)數(shù)
document.images[0]          //第1個(gè)<img>標(biāo)簽           
document.images[i]          //第i-1個(gè)<img>標(biāo)簽

b)通過nane屬性直接引用
<img name="oImage">
document.images.oImage      //document.images.name屬性

c)引用圖片的src屬性
document.images.oImage.src  //document.images.name屬性.src

d)創(chuàng)建一個(gè)圖象
var oImage
oImage = new Image()
document.images.oImage.src="/1.jpg"
同時(shí)在頁面上建立一個(gè)<img>標(biāo)簽與之對應(yīng)就可以顯示

<html>
<img name=oImage>
<script language="javascript">
   var oImage
   oImage = new Image()
   document.images.oImage.src="/1.jpg"
</script>
</html>

----------------------------------------------------------------------

forms集合(頁面中的表單)

a)通過集合引用
document.forms                 //對應(yīng)頁面上的<form>標(biāo)簽
document.forms.length          //對應(yīng)頁面上<form>標(biāo)簽的個(gè)數(shù)
document.forms[0]              //第1個(gè)<form>標(biāo)簽
document.forms[i]              //第i-1個(gè)<form>標(biāo)簽
document.forms[i].length       //第i-1個(gè)<form>中的控件數(shù)
document.forms[i].elements[j]  //第i-1個(gè)<form>中第j-1個(gè)控件

b)通過標(biāo)簽name屬性直接引用
<form name="Myform"><input name="myctrl"></form>
document.Myform.myctrl         //document.表單名.控件名

-----------------------------------------------------------------------
<html>
<!--Text控件相關(guān)Script-->
<form name="Myform">
<input type="text" name="oText">
<input type="password" name="oPswd">
<form>
<script language="javascript">
//獲取文本密碼框的值
document.write(document.Myform.oText.value)
document.write(document.Myform.oPswd.value)
</script>
</html>
-----------------------------------------------------------------------
<html>
<!--Select控件相關(guān)Script-->
<form name="Myform">
<select name="oSelect">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</form>

<script language="javascript">
   //遍歷select控件的option項(xiàng)
   var length
   length=document.Myform.oSelect.length
   for(i=0;i<length;i++)
   document.write(document.Myform.oSelect[i].value)
</script>

<script language="javascript">
   //遍歷option項(xiàng)并且判斷某個(gè)option是否被選中
   for(i=0;i<document.Myform.oSelect.length;i++){
   if(document.Myform.oSelect[i].selected!=true)
   document.write(document.Myform.oSelect[i].value)
   else
   document.write("<font color=red>"+document.Myform.oSelect[i].value+"</font>")   
   }
</script>

<script language="javascript">
   //根據(jù)SelectedIndex打印出選中的option
   //(0到document.Myform.oSelect.length-1)
   i=document.Myform.oSelect.selectedIndex
   document.write(document.Myform.oSelect[i].value)
</script>

<script language="javascript">
   //動(dòng)態(tài)增加select控件的option項(xiàng)
   var oOption = document.createElement("OPTION");
   oOption.text="4";
   oOption.value="4";
   document.Myform.oSelect.add(oOption);
</script>
<html>
-----------------------------------------------------------------------
<Div id="oDiv">Text</Div>
document.all.oDiv                       //引用圖層oDiv
document.all.oDiv.style                 
document.all.oDiv.style.display=""      //圖層設(shè)置為可視
document.all.oDiv.style.display="none"  //圖層設(shè)置為隱藏
/*document.all表示document中所有對象的集合
只有ie支持此屬性,因此也用來判斷瀏覽器的種類*/

相關(guān)文章

  • TypeScrip中泛型的案例詳解

    TypeScrip中泛型的案例詳解

    這篇文章主要介紹了TypeScrip中泛型的案例詳解,本篇文章通過簡要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下
    2021-07-07
  • JS保存和刪除cookie操作 判斷cookie是否存在

    JS保存和刪除cookie操作 判斷cookie是否存在

    本文內(nèi)容講的是:JS保存和刪除cookie操作,判斷cookie是否存在的方法
    2013-11-11
  • JavaScript學(xué)習(xí)筆記整理_關(guān)于表達(dá)式和語句

    JavaScript學(xué)習(xí)筆記整理_關(guān)于表達(dá)式和語句

    下面小編就為大家?guī)硪黄狫avaScript學(xué)習(xí)筆記整理_關(guān)于表達(dá)式和語句。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2016-09-09
  • 深入理解Java線程編程中的阻塞隊(duì)列容器

    深入理解Java線程編程中的阻塞隊(duì)列容器

    這篇文章主要介紹了Java線程編程中的阻塞隊(duì)列容器,介紹了JDK中所提供的一些基本的實(shí)現(xiàn)阻塞隊(duì)列的方法,需要的朋友可以參考下
    2015-12-12
  • JAVASCRIPT對象及屬性

    JAVASCRIPT對象及屬性

    JAVASCRIPT對象及屬性...
    2007-02-02
  • 了解javascript中的Dom操作

    了解javascript中的Dom操作

    DOM 給我們提供了一些方法,讓我們可以使用js來控制頁面中的標(biāo)簽等。下面小編和大家來一起學(xué)習(xí)下吧
    2019-05-05
  • javascript事件模型介紹

    javascript事件模型介紹

    在各種瀏覽器中存在三種事件模型:原始事件模型( original event model),DOM2事件模型,IE事件模型.其中原始的事件模型被所有瀏覽器所支持,而DOM2中所定義的事件模型目前被除了IE以外的所有主流瀏覽器支持。
    2016-05-05
  • 使用Math.floor與Math.random取隨機(jī)整數(shù)的方法詳解

    使用Math.floor與Math.random取隨機(jī)整數(shù)的方法詳解

    本篇文章對使用Math.floor與Math.random取隨機(jī)整數(shù)的方法進(jìn)行了詳細(xì)的分析介紹。需要的朋友參考下
    2013-05-05
  • 將RGB值轉(zhuǎn)換為灰度值的簡單算法

    將RGB值轉(zhuǎn)換為灰度值的簡單算法

    這篇文章主要介紹了將RGB值轉(zhuǎn)換為灰度值的簡單算法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-10-10
  • JS 作用域與作用域鏈詳解

    JS 作用域與作用域鏈詳解

    這篇文章主要介紹了JS 作用域與作用域鏈詳解,十分的細(xì)致全面,這里推薦給小伙伴們,有需要的朋友可以參考下。
    2015-04-04

最新評論