COMMENT 元素 | comment 對象
CUSTOM 元素 | custom 對象
DHTML 對象
代表了在全局樣式表、內(nèi)嵌樣式和 HTML 標(biāo)簽屬性中指定的對象格式和樣式。
成員表
屬性 描述 blockDirection 獲取表明塊元素內(nèi)容的繞排方向的值,是由左至右,還是由右至左。 clipBottom 獲取對象剪裁區(qū)域的底邊坐標(biāo)。 clipLeft 獲取對象剪裁區(qū)域的左邊坐標(biāo)。 clipRight 獲取對象剪裁區(qū)域的右邊坐標(biāo)。 clipTop 獲取對象剪裁區(qū)域的頂邊坐標(biāo)。 onOffBehavior 獲取表明指定的 Microsoft® DirectAnimation® 行為是否正在運行的對象。
方法 描述 getAttribute 獲取指定標(biāo)簽屬性的值。 getExpression 獲取給定屬性的表達(dá)式。 setAttribute 設(shè)置指定標(biāo)簽屬性的值。 setExpression 設(shè)置指定對象的表達(dá)式。
樣式標(biāo)簽屬性 樣式屬性 描述 ACCELERATOR accelerator 獲取表明對象是否包含快捷鍵的字符串。 background-attachment backgroundAttachment 設(shè)置或獲取背景圖像如何附加到文檔內(nèi)的對象中。 background-color backgroundColor 設(shè)置或獲取對象內(nèi)容后的顏色。 background-image backgroundImage 設(shè)置或獲取對象的背景圖像。 background-position-x backgroundPositionX 設(shè)置或獲取 backgroundPosition 屬性的 x 坐標(biāo)。 background-position-y backgroundPositionY 設(shè)置或獲取 backgroundPosition 屬性的 y 坐標(biāo)。 background-repeat backgroundRepeat 設(shè)置或獲取對象的 backgroundImage 屬性如何平鋪。 behavior behavior 設(shè)置或獲取 DHTML 行為的位置。 border-bottom-color borderBottomColor 設(shè)置或獲取對象下邊框的顏色。 border-bottom-style borderBottomStyle 設(shè)置或獲取對象下邊框的樣式。 border-bottom-width borderBottomWidth 設(shè)置或獲取對象下邊框的寬度。 border-collapse borderCollapse 設(shè)置或獲取表明表格行和單元格邊框是組合為單一邊框還是像標(biāo)準(zhǔn) HTML 那樣分離。 border-color borderColor 設(shè)置或獲取對象的邊框顏色。 border-left-color borderLeftColor 設(shè)置或獲取對象左邊框的顏色。 border-left-style borderLeftStyle 設(shè)置或獲取對象左邊框的樣式。 border-left-width borderLeftWidth 設(shè)置或獲取對象左邊框的寬度。 border-right-color borderRightColor 設(shè)置或獲取對象右邊框的顏色。 border-right-style borderRightStyle 設(shè)置或獲取對象右邊框的樣式。 border-right-width borderRightWidth 設(shè)置或獲取對象右邊框的寬度。 border-style borderStyle 設(shè)置或獲取對象上下左右邊框的樣式。 border-top-color borderTopColor 設(shè)置或獲取對象上邊框的顏色。 border-top-style borderTopStyle 設(shè)置或獲取對象上邊框的樣式。 border-top-width borderTopWidth 設(shè)置或獲取對象上邊框的寬度。 border-width borderWidth 設(shè)置或獲取對象上下左右邊框的寬度。 bottom bottom 設(shè)置或獲取對象相對于文檔層次中下個定位對象的底部的位置。 clear clear 設(shè)置或獲取對象是否允許在其左側(cè)、右側(cè)或兩邊放置浮動對象,以防下段文本顯示在浮動對象上。 color color 設(shè)置或獲取對象文本的顏色。 cursor cursor 設(shè)置或獲取當(dāng)鼠標(biāo)指針指向對象時所使用的鼠標(biāo)指針。 direction direction 設(shè)置或獲取對象的閱讀順序。 display display 設(shè)置或獲取對象是否要渲染。 font-family fontFamily 設(shè)置或獲取對象文本所使用的字體名稱。 font-size fontSize 設(shè)置或獲取對象文本使用的字體大小。 font-style fontStyle 設(shè)置或獲取對象的字體樣式,如斜體、常規(guī)或傾斜。 font-variant fontVariant 設(shè)置或獲取對象文本是否以小型大寫字母顯示。 font-weight fontWeight 設(shè)置或獲取對象的字體寬度。 hasLayout 獲取表明對象是否有布局的值。 height height 設(shè)置或獲取對象的高度。 ime-mode imeMode 獲取輸入方法編輯器(IME)的狀態(tài)。 layout-flow layoutFlow 設(shè)置或獲取對象內(nèi)容的方向和繞排方向。 layout-grid-char layoutGridChar 設(shè)置或獲取用于渲染元素文本內(nèi)容的字符網(wǎng)格大小。 layout-grid-line layoutGridLine 設(shè)置或獲取用于渲染元素文本內(nèi)容的網(wǎng)格線值。 layout-grid-mode layoutGridMode 設(shè)置或獲取文本布局網(wǎng)格是否使用二維。 layout-grid-type layoutGridType 設(shè)置或獲取用于渲染元素文本內(nèi)容的網(wǎng)格類型。 left left 設(shè)置或獲取對象相對于文檔層次中下個定位對象的左邊界的位置。 letter-spacing letterSpacing 設(shè)置或獲取對象的字符間附加空間的總和。 line-break lineBreak 設(shè)置或獲取日本文本的換行規(guī)則。 line-height lineHeight 設(shè)置或獲取對象兩行間的距離。 list-style-image listStyleImage 獲取要為對象應(yīng)用的列表項目符號的圖像。 list-style-position listStylePosition 獲取相對于對象內(nèi)容如何繪制項目符號。 list-style-type listStyleType 獲取對象預(yù)定義的項目符號類型。 margin margin 設(shè)置或獲取對象的上下左右邊距。 margin-bottom marginBottom 設(shè)置或獲取對象的下邊距寬度。 margin-left marginLeft 設(shè)置或獲取對象的左邊距寬度。 margin-right marginRight 設(shè)置或獲取對象的右邊距寬度。 margin-top marginTop 設(shè)置或獲取對象的上邊距寬度。 min-height minHeight 設(shè)置或獲取元素的最小高度。 overflow overflow 設(shè)置或獲取表明當(dāng)內(nèi)容超出對象高度或?qū)挾葧r如何管理對象內(nèi)容的值。 overflow-x overflowX 設(shè)置或獲取當(dāng)內(nèi)容超出對象寬度時如何管理對象內(nèi)容。 overflow-y overflowY 設(shè)置或獲取當(dāng)內(nèi)容超出對象高度時如何管理對象內(nèi)容。 padding padding 設(shè)置或獲取要在對象和其邊距或若存在的邊框的話就是對象和其邊框之間要插入的全部空間。 padding-bottom paddingBottom 設(shè)置或獲取要在對象下邊框和內(nèi)容之間插入的空間總量。 padding-left paddingLeft 設(shè)置或獲取要在對象左邊框和內(nèi)容之間插入的空間總量。 padding-right paddingRight 設(shè)置或獲取要在對象右邊框和內(nèi)容之間插入的空間總量。 padding-top paddingTop 設(shè)置或獲取對象上邊框和內(nèi)容之間插入的空間總量。 page-break-after pageBreakAfter 設(shè)置或獲取表明對象后發(fā)生換頁的字符串。 page-break-before pageBreakBefore 設(shè)置或獲取表明對象前發(fā)生換頁的字符串。 position position 設(shè)置或獲取對象所使用的定位方式。 right right 設(shè)置或獲取對象相對于文檔層次中下個已定位的對象的右邊界的位置。 ruby-align rubyAlign 獲取由 RT 對象指定的注音文本的位置。 ruby-overhang rubyOverhang 獲取由 RT 對象指定的注音文本的位置。 ruby-position rubyPosition 獲取由 RT 對象指定的注音文本的位置。 scrollbar-3dlight-color scrollbar3dLightColor 設(shè)置或獲取滾動條上滾動按鈕和滾動滑塊的左上顏色。 scrollbar-arrow-color scrollbarArrowColor 設(shè)置或獲取滾動箭頭標(biāo)識的顏色。 scrollbar-base-color scrollbarBaseColor 設(shè)置或獲取滾動條的主要顏色,其中包含滾動按鈕和滾動滑塊。 scrollbar-darkshadow-color scrollbarDarkShadowColor 設(shè)置或獲取滾動條上滑槽的顏色。 scrollbar-face-color scrollbarFaceColor 設(shè)置或獲取滾動條和滾動條的滾動箭頭的顏色。 scrollbar-highlight-color scrollbarHighlightColor 設(shè)置或獲取滾動框和滾動條滾動箭頭的左上邊緣顏色。 scrollbar-shadow-color scrollbarShadowColor 設(shè)置或獲取滾動框和滾動條滾動箭頭的右下邊緣顏色。 scrollbar-track-color scrollbarTrackColor 設(shè)置或獲取滾動條軌跡元素的顏色。 float styleFloat 設(shè)置或獲取文本要繞排到對象的哪一側(cè)。 table-layout tableLayout 獲取表明表格布局是否固定的字符串。 text-align textAlign 設(shè)置或獲取對象中的文本是左對齊、右對齊、居中對齊還是兩端對齊。 text-align-last textAlignLast 設(shè)置或獲取如何排列對象的最后一行或僅有的一行。 text-autospace textAutospace 設(shè)置或獲取自動留空和文本的窄空間寬度調(diào)整。 text-decoration textDecoration 設(shè)置或獲取對象中的文本是否有閃爍、刪除線、上劃線或下劃線的樣式。 text-indent textIndent 設(shè)置或獲取對象中文本的縮進(jìn)。 text-justify textJustify 設(shè)置或獲取對象內(nèi)的文本所使用的對齊類型。 text-kashida-space textKashidaSpace 設(shè)置或獲取對象內(nèi)文本對齊行時所使用空白擴(kuò)展的 kashida 擴(kuò)展的倍率。 text-overflow textOverflow 設(shè)置或獲取表明是否顯示省略號以表明文本溢出的值。 text-transform textTransform 設(shè)置或獲取對象中文本的渲染方式。 text-underline-position textUnderlinePosition 設(shè)置或獲取對象的 textDecoration 屬性中設(shè)置的下劃線的位置。 top top 設(shè)置或獲取對象相對于文檔層次中下個定位對象的上邊界的位置。 unicode-bidi unicodeBidi 設(shè)置或獲取關(guān)于雙向法則的嵌入級別。 vertical-align verticalAlign 設(shè)置或獲取對象的垂直排列。 visibility visibility 設(shè)置或獲取對象的內(nèi)容是否顯示。 white-space whiteSpace 設(shè)置或獲取對象中是否自動換行。 width width 設(shè)置或獲取對象的寬度。 word-break wordBreak 設(shè)置或獲取單詞內(nèi)的換行行為,特別是對象中出現(xiàn)多語言的情況。 word-spacing wordSpacing 設(shè)置或獲取對象中單詞間的附加空間總量。 word-wrap wordWrap 設(shè)置或獲取當(dāng)內(nèi)容超過其容器邊界時是否斷詞。 writing-mode writingMode 設(shè)置或獲取對象內(nèi)容的方向和繞排。 z-index zIndex 設(shè)置或獲取定位對象的堆疊次序。 zoom zoom 設(shè)置或獲取對象的放大比例。
注釋
currentStyle 對象返回了元素上的樣式表,但是 style 對象只返回通過 STYLE 標(biāo)簽屬性應(yīng)用到元素的內(nèi)嵌樣式。因此,通過 currentStyle 對象獲取的樣式值可能與通過 style 對象獲取的樣式值不同。例如,如果段落的 color 屬性值通過鏈接或嵌入樣式表設(shè)置為紅色( red ),而不是內(nèi)嵌的話,對象.currentStyle.color 將返回正確的顏色,而對象 style.color 不能返回值。但是,如果用戶指定了 <P STYLE="color:'red'">,currentStyle 和 STYLE 對象都將返回值 red。
currentStyle 對象反映了樣式表中的樣式優(yōu)先順序。在 HTML 中此順序為:
- 內(nèi)嵌樣式
- 樣式表規(guī)則
- HTML 標(biāo)簽屬性
- HTML 標(biāo)簽的內(nèi)部定義
從而,currentStyle 對象將為 bold 標(biāo)簽返回 fontWeight 值 normal,若在樣式表中為此標(biāo)簽指定了 normal。
currentStyle 返回反映頁面所應(yīng)用的樣式設(shè)置的值,但可能并不反映獲取值時渲染所采用的值。例如,樣式值設(shè)置為 "color:red; display:none" 的對象,將返回 currentStyle.color 為 red,盡管該對象并不在頁面上渲染。也就是說,currentStyle 對象并不受渲染與否的綁定。在下面示例區(qū)的第三個例子演示了此行為。禁用的樣式表也不影響 currentStyle 值。
返回值的單位與設(shè)置對象時的單位相同。例如,若對象的顏色是以內(nèi)嵌 STYLE="color:'green'" 的格式設(shè)置的,那么 object.currentStyle.color 將返回 green 而不是 #00FF00 (與綠色相等的紅綠藍(lán)十六進(jìn)制值)。但是,當(dāng) currentStyle 對象返回對象值的時候出現(xiàn)在作者所設(shè)置的對象值中的大寫和多余的空白將被去掉。
currentStyle 對象支持用戶自定義的樣式規(guī)則屬性。請參看示例區(qū)的第二個例子。
currentStyle 對象是異步的。這意味著樣式不可能被設(shè)置后馬上就能查詢,而是返回舊值。因此,對于含有 addImport 這樣方法的想要獲得所期待的 currentStyle 行為的腳本,該腳本需要包含一個調(diào)用方法的函數(shù)和一個檢查 currentStyle 的函數(shù)。對于需要在頁面裝載的時候檢查當(dāng)前屬性的腳本,腳本必須等到 body 元素裝入且頁面被選然后,否則 currentStyle 的值可能不反映所顯示的情況。
此對象在 Microsoft® Internet Explorer 5 的腳本中可用。
示例
下面的例子使用 currentStyle 對象將文本顏色設(shè)置為棕色。如果你單擊著色區(qū)域并且背景顏色與文本顏色相同,checkColor 函數(shù)就會更改背景顏色,以方便閱讀文本。否則,該函數(shù)不做任何操作。
這個例子僅當(dāng)主體和文本顏色同時使用顏色名稱或 RGB 十六進(jìn)制值時可用,混合使用時無效。
<SCRIPT> function checkColor(oObj) { if (oObj.currentStyle.backgroundColor == 'brown') { oObj.style.backgroundColor = 'white'; } else : } </SCRIPT> </HEAD> : <P STYLE="background-color: 'brown'" onclick="checkColor(this)">這個例子使用 currentStyle 對象獲取創(chuàng)建于樣式規(guī)則的用戶自定義屬性。alert 返回值 myvalue。
<STYLE> P { myproperty:myvalue } </STYLE> <BODY> <P ID=oPrgrph> : <SCRIPT> alert(oPrgrph.currentStyle.myproperty) </SCRIPT>這個例子由 currentStyle 對象返回的 td 對象寬度是其層疊寬度值而不是屏幕上渲染的寬度值。
<BODY ID=oBdy> : <TABLE BORDER> <TR><TD WIDTH=1100 ID=oTblD>text</TD></TR> </TABLE> : <SCRIPT> alert("TD 對象 currentStyle.width 為 " + oTblD.currentStyle.width + ".\n" + "窗口的寬度為 " + oBdy.clientWidth + "px.\n屏幕的寬度為 " + screen.width + "px." ) </SCRIPT>
標(biāo)準(zhǔn)信息
沒有應(yīng)用于此對象的公共標(biāo)準(zhǔn)。
應(yīng)用到
a, acronym, address, applet, b, bdo, big, blockQuote, body, br, button, caption, center, cite, code, col, colGroup, custom, dd, del, dfn, dir, div, dl, dt, em, embed, fieldSet, font, form, hn, html, i, img, input type=button, input type=checkbox, input type=file, input type=image, input type=password, input type=radio, input type=reset, input type=submit, input type=text, ins, isIndex, kbd, label, legend, li, listing, marquee, menu, noBr, object, ol, option, p, plainText, pre, q, s, samp, select, small, span, strike, strong, sub, sup, table, tBody, td, textArea, tFoot, th, tHead, tr, tt, u, ul, var, wbr, xmp
參看
style