www.fgks.org   »   [go: up one dir, main page]

Click to Rate and Give Feedback
 currentStyle Object
currentStyle Object

Represents the cascaded format and style of the object as specified by global style sheets, inline styles, and HTML attributes.

Members Table

The following table lists the members exposed by the currentStyle object.

Attributes/Properties
Show:
AttributePropertyDescription
blockDirection Gets a string value that indicates whether the content in the block element flows from left to right, or from right to left.
clipBottom Gets the bottom coordinate of the object clipping region.
counter-increment New for Windows Internet Explorer 8 counterIncrement Retrieves a list of counters to increment.
counter-reset New for Internet Explorer 8 counterReset Retrieves a list of counters to create or reset to zero.
-ms-box-sizing New for Internet Explorer 8 msBoxSizing Retrieves the box model to use for object sizing.
onOffBehavior Gets an object that indicates whether the specified Microsoft DirectAnimation behavior is running.
MethodDescription
getAttribute Retrieves the value of the specified attribute.
getExpression Retrieves the expression for the given property.
setAttribute Sets the value of the specified attribute.
setExpression Sets an expression for the specified object.
Style attributeStyle propertyDescription
ACCELERATORaccelerator Retrieves a string that indicates whether the object contains an accelerator key.
background-attachmentbackgroundAttachment Retrieves how the background image is attached to the object within the document.
background-colorbackgroundColor Retrieves the color behind the content of the object.
background-imagebackgroundImage Retrieves the background image of the object.
background-position-xbackgroundPositionX Retrieves the x-coordinate of the backgroundPosition property.
background-position-ybackgroundPositionY Retrieves the y-coordinate of the backgroundPosition property.
background-repeatbackgroundRepeat Retrieves how the backgroundImage property of the object is tiled.
behaviorbehavior Retrieves the location of the Dynamic HTML (DHTML) behavior.
border-bottom-colorborderBottomColor Retrieves the color of the bottom border of the object.
border-bottom-styleborderBottomStyle Retrieves the style of the bottom border of the object.
border-bottom-widthborderBottomWidth Retrieves the width of the bottom border of the object.
border-collapseborderCollapse Retrieves a value that indicates whether the row and cell borders of a table are joined in a single border or detached as in standard HTML.
border-colorborderColor Retrieves the border color of the object.
border-left-colorborderLeftColor Retrieves the color of the left border of the object.
border-left-styleborderLeftStyle Retrieves the style of the left border of the object.
border-left-widthborderLeftWidth Retrieves the width of the left border of the object.
border-right-colorborderRightColor Retrieves the color of the right border of the object.
border-right-styleborderRightStyle Retrieves the style of the right border of the object.
border-right-widthborderRightWidth Retrieves the width of the right border of the object.
border-spacing New for Internet Explorer 8 borderSpacing Retrieves the distance between the borders of adjoining cells in a table.
border-styleborderStyle Retrieves the style of the left, right, top, and bottom borders of the object.
border-top-colorborderTopColor Retrieves the color of the top border of the object.
border-top-styleborderTopStyle Retrieves the style of the top border of the object.
border-top-widthborderTopWidth Retrieves the width of the top border of the object.
border-widthborderWidth Retrieves the width of the left, right, top, and bottom borders of the object.
bottombottom Retrieves the bottom position of the object in relation to the bottom of the next positioned object in the document hierarchy.
caption-side New for Internet Explorer 8 captionSide Retrieves where the caption of a table is located.
clearclear Retrieves whether the object allows floating objects on its left side, right side, or both, so that the next text displays past the floating objects.
clipLeft Gets the left coordinate of the object clipping region.
clipRight Gets the right coordinate of the object clipping region.
clipTop Gets the top coordinate of the object clipping region.
colorcolor Retrieves the color of the text of the object.
content New for Internet Explorer 8 content Retrieves generated content to insert before or after an element.
cursorcursor Retrieves the type of cursor to display as the mouse pointer moves over the object.
directiondirection Retrieves the reading order of the object.
displaydisplay Retrieves whether the object is rendered.
font-familyfontFamily Retrieves the name of the font used for text in the object.
font-sizefontSize Retrieves a value that indicates the font size used for text in the object.
font-stylefontStyle Retrieves the font style of the object as italic, normal, or oblique.
font-variantfontVariant Retrieves whether the text of the object is in small capital letters.
fontWeight Gets the numeric weight of the font of the object.
hasLayout Gets a value that indicates whether the object has layout.
heightheight Retrieves the height of the object.
ime-modeimeMode Retrieves the state of an Input Method Editor (IME).
layout-flowlayoutFlow Retrieves the direction and flow of the content in the object.
layout-grid-charlayoutGridChar Retrieves the size of the character grid used for rendering the text content of an element.
layout-grid-linelayoutGridLine Retrieves the gridline value used for rendering the text content of an element.
layout-grid-modelayoutGridMode Retrieves whether the text layout grid uses two dimensions.
layout-grid-typelayoutGridType Retrieves the type of grid used for rendering the text content of an element.
leftleft Retrieves the position of the object relative to the left edge of the next positioned object in the document hierarchy.
letter-spacingletterSpacing Retrieves the amount of additional space between letters in the object.
line-breaklineBreak Retrieves line-breaking rules for text in selected languages such as Japanese, Chinese and Korean.
line-heightlineHeight Retrieves the distance between lines in the object.
list-style-imagelistStyleImage Retrieves a value that indicates which image to use as a list-item marker for the object.
list-style-positionlistStylePosition Retrieves a variable that indicates how the list-item marker is drawn relative to the content of the object.
list-style-typelistStyleType Retrieves the predefined type of the line-item marker for the object.
marginmargin Retrieves the width of the top, right, bottom, and left margins of the object.
margin-bottommarginBottom Retrieves the height of the bottom margin of the object.
margin-leftmarginLeft Retrieves the width of the left margin of the object.
margin-rightmarginRight Retrieves the width of the right margin of the object.
margin-topmarginTop Retrieves the height of the top margin of the object.
max-heightmaxHeight Retrieves the maximum height for an element.
max-widthmaxWidth Retrieves the maximum width for an element.
min-heightminHeight Retrieves the minimum height for an element.
min-widthminWidth Retrieves the minimum width for an element.
-ms-interpolation-modemsInterpolationMode Retrieves the interpolation (resampling) method used to stretch images.
orphans New for Internet Explorer 8 orphans Retrieves the minimum number of lines of a paragraph that must appear at the bottom of a page.
outline New for Internet Explorer 8 outline Retrieves the color, style, and width of the outline frame.
outline-color New for Internet Explorer 8 outlineColor Retrieves the color of the outline frame.
outline-style New for Internet Explorer 8 outlineStyle Retrieves the style of the outline frame.
outline-width New for Internet Explorer 8 outlineWidth Retrieves the width of the outline frame.
overflowoverflow Retrieves a value indicating how to manage the content of the object when the content exceeds the height or width of the object.
overflow-xoverflowX Retrieves how to manage the content of the object when the content exceeds the width of the object.
overflow-yoverflowY Retrieves how to manage the content of the object when the content exceeds the height of the object.
paddingpadding Retrieves the amount of space to insert between the object and its margin or, if there is a border, between the object and its border.
padding-bottompaddingBottom Retrieves the amount of space to insert between the bottom border of the object and the content.
padding-leftpaddingLeft Retrieves the amount of space to insert between the left border of the object and the content.
padding-rightpaddingRight Retrieves the amount of space to insert between the right border of the object and the content.
padding-toppaddingTop Retrieves the amount of space to insert between the top border of the object and the content.
page-break-afterpageBreakAfter Retrieves a value indicating whether a page break occurs after the object.
page-break-beforepageBreakBefore Retrieves a string indicating whether a page break occurs before the object.
page-break-inside New for Internet Explorer 8 pageBreakInside Retrieves a string indicating whether a page break is allowed to occur inside the object.
positionposition Retrieves the type of positioning used for the object.
rightright Retrieves the position of the object relative to the right edge of the next positioned object in the document hierarchy.
ruby-alignrubyAlign Retrieves the position of the ruby text specified by the rt object.
ruby-overhangrubyOverhang Retrieves the position of the ruby text specified by the rt object.
ruby-positionrubyPosition Retrieves the position of the ruby text specified by the rt object.
scrollbar-3dlight-colorscrollbar3dLightColor Retrieves the color of the top and left edges of the scroll box and scroll arrows of a scroll bar.
scrollbar-arrow-colorscrollbarArrowColor Retrieves the color of the arrow elements of a scroll arrow.
scrollbar-base-colorscrollbarBaseColor Retrieves the color of the main elements of a scroll bar, which include the scroll box, track, and scroll arrows.
scrollbar-darkshadow-colorscrollbarDarkShadowColor Retrieves the color of the gutter of a scroll bar.
scrollbar-face-colorscrollbarFaceColor Retrieves the color of the scroll box and scroll arrows of a scroll bar.
scrollbar-highlight-colorscrollbarHighlightColor Retrieves the color of the top and left edges of the scroll box and scroll arrows of a scroll bar.
scrollbar-shadow-colorscrollbarShadowColor Retrieves the color of the bottom and right edges of the scroll box and scroll arrows of a scroll bar.
scrollbar-track-colorscrollbarTrackColor Retrieves the color of the track element of a scroll bar.
floatstyleFloat Retrieves on which side of the object the text will flow.
table-layouttableLayout Retrieves a string that indicates whether the table layout is fixed.
text-aligntextAlign Retrieves whether the text in the object is left-aligned, right-aligned, centered, or justified.
text-align-lasttextAlignLast Retrieves how to align the last line or only line of text in the object.
text-autospacetextAutospace Retrieves the autospacing and narrow space width adjustment of text.
text-decorationtextDecoration Retrieves a value that indicates whether the text in the object has blink, line-through, overline, or underline decorations.
text-indenttextIndent Retrieves the indentation of the first line of text in the object.
text-justifytextJustify Retrieves the type of alignment used to justify text in the object.
text-kashida-spacetextKashidaSpace Retrieves the ratio of kashida expansion to white space expansion when justifying lines of text in the object.
text-overflowtextOverflow Retrieves a value that indicates whether to render ellipses(...) to indicate text overflow.
text-transformtextTransform Retrieves the rendering of the text in the object.
text-underline-positiontextUnderlinePosition Retrieves the position of the underline decoration that is set through the textDecoration property of the object.
toptop Retrieves the position of the object relative to the top of the next positioned object in the document hierarchy.
unicode-bidiunicodeBidi Retrieves the level of embedding with respect to the bidirectional algorithm.
vertical-alignverticalAlign Retrieves the vertical alignment of the object.
visibilityvisibility Retrieves whether the content of the object is displayed.
white-spacewhiteSpace Retrieves a value that indicates whether lines are automatically broken inside the object.
widows New for Internet Explorer 8 widows Retrieves the minimum number of lines of a paragraph that must appear at the top of a page.
widthwidth Retrieves the width of the object.
word-breakwordBreak Retrieves line-breaking behavior within words, particularly where multiple languages appear in the object.
word-spacingwordSpacing Retrieves the amount of additional space between words in the object.
word-wrapwordWrap Retrieves whether to break words when the content exceeds the boundaries of its container.
writing-modewritingMode Retrieves the direction and flow of the content in the object.
z-indexzIndex Retrieves the stacking order of positioned objects.
zoomzoom Retrieves the magnification scale of the object.

Remarks

The currentStyle object returns the cascaded styles on an element, but the style object returns only the styles that have been applied inline on an element through the style attribute. Thus, the style values retrieved through the currentStyle object might differ from the style values retrieved through the style object. For example, if the color property is set on a paragraph only through a linked or embedded style sheet, and not inline, then object.currentStyle.color returns the color, whereas object.style.color does not return a value. If, however, the author specifies <P STYLE="color:'red'", the currentStyle and style objects return the value red.

The currentStyle object reflects the order of style precedence in cascading style sheets (CSS). The CSS order of precedence for the presentation of HTML is:

  1. Inline styles
  2. Style sheet rules
  3. Attributes on HTML tags
  4. Intrinsic definition of the HTML tag

Accordingly, the currentStyle object returns the fontWeight value normal on a bold tag if normal is specified in a style sheet.

The currentStyle object returns values that reflect the applied style settings for the page and might not reflect what is rendering at the time a value is retrieved. For example, an object that has "color:red; display:none" returns currentStyle.color as red even though the object is not rendered on the page. The currentStyle object, then, is not affected by the rendering constraints. The third example in the Example section demonstrates this behavior. Disabled style sheets also do not affect currentStyle values.

The returned value is in the same units as those used to set the object. For example, if the color of an object is set inline using STYLE="color:'green'", then object.currentStyle.color returns green and not #00FF00 (the red-green-blue hexadecimal equivalent to green). However, capitalization and redundant white space that appear in the object values set by the author are lost when the currentStyle object returns the object values.

The currentStyle object supports user-defined properties in style rules. See the second example in the Example section.

The currentStyle object is asynchronous. This means a style cannot be set and then immediately queried—instead, the old value is returned. Thus, for a script to obtain the expected behavior of currentStyle with methods such as addImport, the script needs to include a function that calls the method and a function that checks currentStyle. For a script to check the current style while a page is loading, the script must wait until the body element is loaded and the page has rendered, or the value of currentStyle might not reflect what is being displayed.

This object is available in script as of Microsoft Internet Explorer 5.

Examples

This example uses the currentStyle object to set the text color to brown. If you click a colored area and the background color is the same as the text color, the checkColor function changes the background color, so the text can be read. Otherwise, the function takes no action.

This example works only if the body and text colors are set using either color names or red-green-blue hexadecimal values, but not a mix of the two.

<SCRIPT>
function checkColor(oObj)
{
  if (oObj.currentStyle.backgroundColor == 'brown')
	{
        oObj.style.backgroundColor = 'white';
	}
  else
	:
}
</SCRIPT>
</HEAD>
:
<P STYLE="background-color: 'brown'"
    >
This feature requires Microsoft® Internet Explorer 5 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

This example uses the currentStyle object to retrieve values of the user-defined property created in the style rule. The alert returns the value myvalue.

<STYLE>
    P { myproperty:myvalue }
</STYLE>
<BODY>
<P ID=oPrgrph>
:
<SCRIPT>
alert(oPrgrph.currentStyle.myproperty)
</SCRIPT>
This feature requires Microsoft® Internet Explorer 5 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

This example shows that the td object width returned by the currentStyle object is its cascaded width value rather than the width rendered on the screen.

<BODY ID=oBdy>
:
<TABLE BORDER>
<TR><TD WIDTH=1100 ID=oTblD>text</TD></TR>
</TABLE>
:
<SCRIPT>
alert("The TD object currentStyle.width is " + oTblD.currentStyle.width +
    ".\nThe width of the window is " + oBdy.clientWidth +
    "px.\nThe width of the screen is " + screen.width + "px." )
</SCRIPT>
This feature requires Microsoft® Internet Explorer 5 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

Standards Information

There is no public standard that applies to this object.

Applies To

A, ABBR, 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

See Also

style
Tags What's this?: Add a tag
Community Content
 
Add Community Content
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker
DCSIMG