Packagecssom.view
Interfacepublic interface TextRectangle

Introduced in: DOM 0 

Objects implementing the TextRectangle interface represent a rectangular box.

View the examples

See also

MSDN: TextRectangle Object
W3C CSSOM Views Specification: TextRectangle


Public Properties
 PropertyDefined By
  CSSOM View bottom : Number
[read-only] Returns the distance between the top of the viewport and the bottom of the rectangle box as number of CSS pixels.
TextRectangle
  Non-Standard height : Number
[read-only]
TextRectangle
  CSSOM View left : Number
[read-only] Returns the distance between the left of the viewport and the left of the rectangle box as number of CSS pixels.
TextRectangle
  CSSOM View right : Number
[read-only] Returns the distance between the left of the viewport and the right of the rectangle box as number of CSS pixels.
TextRectangle
  CSSOM View top : Number
[read-only] Returns the distance between the top of the viewport and the top of the rectangle box as number of CSS pixels.
TextRectangle
  Non-Standard width : Number
[read-only]
TextRectangle
Property Detail
CSSOM View bottomproperty
bottom:Number  [read-only]

Product Versions : Internet Explorer 5.5 Internet Explorer 6.0 Internet Explorer 7.0 Internet Explorer 8.0 as IE7 Internet Explorer 8.0 as IE8 Firefox 2.0 Firefox 3.0 Firefox 3.1b Safari 3.0 Safari 3.1 Safari 4.0b Chrome 1.0 Chrome 2.0 Opera 9.62 Opera 10.0a
Introduced in: DOM 0 

Returns the distance between the top of the viewport and the bottom of the rectangle box as number of CSS pixels.


Implementation
    public function get bottom():Number

See also


Example
         <script>
         function getCoords(oObject) {
             oBndRct = oObject.getBoundingClientRect();
             alert("Bounding rectangle = \nUpper left coordinates: "
             + oBndRct.left + " " + oBndRct.top +
             "\nLower right coordinates: "
             + oBndRct.right + " " + oBndRct.bottom);
         }
         </script>
         </head>    
         <body>
         <p id=oPara onclick="getCoords(this)">
heightproperty 
height:Number  [read-only]

Product Versions : Internet Explorer 5.5 Internet Explorer 6.0 Internet Explorer 7.0 Internet Explorer 8.0 as IE7 Internet Explorer 8.0 as IE8 Firefox 2.0 Firefox 3.0 Firefox 3.1b Safari 3.0 Safari 3.1 Safari 4.0b Chrome 1.0 Chrome 2.0 Opera 9.62 Opera 10.0a

Non-standard (Mozilla)


Implementation
    public function get height():Number

See also

CSSOM View leftproperty 
left:Number  [read-only]

Product Versions : Internet Explorer 5.5 Internet Explorer 6.0 Internet Explorer 7.0 Internet Explorer 8.0 as IE7 Internet Explorer 8.0 as IE8 Firefox 2.0 Firefox 3.0 Firefox 3.1b Safari 3.0 Safari 3.1 Safari 4.0b Chrome 1.0 Chrome 2.0 Opera 9.62 Opera 10.0a
Introduced in: DOM 0 

Returns the distance between the left of the viewport and the left of the rectangle box as number of CSS pixels.


Implementation
    public function get left():Number

See also


Example
         <script>
         function getCoords(oObject) {
             oBndRct = oObject.getBoundingClientRect();
             alert("Bounding rectangle = \nUpper left coordinates: "
             + oBndRct.left + " " + oBndRct.top +
             "\nLower right coordinates: "
             + oBndRct.right + " " + oBndRct.bottom);
         }
         </script>
         </head>    
         <body>
         <p id=oPara onclick="getCoords(this)">
CSSOM View rightproperty 
right:Number  [read-only]

Product Versions : Internet Explorer 5.5 Internet Explorer 6.0 Internet Explorer 7.0 Internet Explorer 8.0 as IE7 Internet Explorer 8.0 as IE8 Firefox 2.0 Firefox 3.0 Firefox 3.1b Safari 3.0 Safari 3.1 Safari 4.0b Chrome 1.0 Chrome 2.0 Opera 9.62 Opera 10.0a
Introduced in: DOM 0 

Returns the distance between the left of the viewport and the right of the rectangle box as number of CSS pixels.


Implementation
    public function get right():Number

See also


Example
         <script>
         function getCoords(oObject) {
             oBndRct = oObject.getBoundingClientRect();
             alert("Bounding rectangle = \nUpper left coordinates: "
             + oBndRct.left + " " + oBndRct.top +
             "\nLower right coordinates: "
             + oBndRct.right + " " + oBndRct.bottom);
         }
         </script>
         </head>    
         <body>
         <p id=oPara onclick="getCoords(this)">
CSSOM View topproperty 
top:Number  [read-only]

Product Versions : Internet Explorer 5.5 Internet Explorer 6.0 Internet Explorer 7.0 Internet Explorer 8.0 as IE7 Internet Explorer 8.0 as IE8 Firefox 2.0 Firefox 3.0 Firefox 3.1b Safari 3.0 Safari 3.1 Safari 4.0b Chrome 1.0 Chrome 2.0 Opera 9.62 Opera 10.0a
Introduced in: DOM 0 

Returns the distance between the top of the viewport and the top of the rectangle box as number of CSS pixels.


Implementation
    public function get top():Number

See also


Example
         <script>
         function getCoords(oObject) {
             oBndRct = oObject.getBoundingClientRect();
             alert("Bounding rectangle = \nUpper left coordinates: "
             + oBndRct.left + " " + oBndRct.top +
             "\nLower right coordinates: "
             + oBndRct.right + " " + oBndRct.bottom);
         }
         </script>
         </head>    
         <body>
         <p id=oPara onclick="getCoords(this)">
widthproperty 
width:Number  [read-only]

Product Versions : Internet Explorer 5.5 Internet Explorer 6.0 Internet Explorer 7.0 Internet Explorer 8.0 as IE7 Internet Explorer 8.0 as IE8 Firefox 2.0 Firefox 3.0 Firefox 3.1b Safari 3.0 Safari 3.1 Safari 4.0b Chrome 1.0 Chrome 2.0 Opera 9.62 Opera 10.0a

Non-standard (Mozilla)


Implementation
    public function get width():Number

See also

Examples
In the following excerpt from the Gettysburg Address, four TextRectangle objects are contained in the b element (bold text).
     <p>Four score and seven years ago <b>our fathers<br>
     brought forth . . . a new nation, conceived in liberty<br>
     and dedicated to the proposition that all men are<br>
     created equal.</b> Now we are engaged in a great civil war . . . 
     </p>
     

The four TextRectangle objects are:

  1. "our fathers"
  2. "brought forth . . . a new nation, conceived in liberty"
  3. "and dedicated to the proposition that all men are"
  4. "created equal"

If you resize the window containing this text, the TextRectangle objects do not update. Because the objects are a snapshot of the layout, the objects should update after an onresize event occurs.

The width of the TextRectangle may not be identical to the width of the TextRange it contains. A TextRange is only as wide as the text, but a TextRectangle is as wide as the element containing that text.