Export (0) Print
Expand All

pixelHeight property

Sets or retrieves the height of the object.

Syntax

pixelHeight: <integer>

Property values

integer

An Integer that specifies or receives the height, in pixels.

CSS information

Applies ToAll elements
Mediavisual
Inheritedno
Initial Value

Remarks

Setting this property changes the value of the height without changing the units designator. Unlike the height property, this property's value is an integer, not a string, and is always interpreted in pixels.

For more information about how to access the dimension and location of objects on the page through the Dynamic HTML (DHTML) Document Object Model (DOM), see Measuring Element Dimension and Location with CSSOM in Internet Explorer 9.

Examples

This example uses a timer to increment the pixelHeight property.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/pixelWidth.htm


<!DOCTYPE html>
<html>
<head>
  <title>pixelWidth</title>
</head>

<body onload="scaleThis(); moveThis(); scaleThis2(); moveThis2()">

  <span style="position: absolute; top: 5px; left: 5px; color: white; background-color: black">SAMPLE SHOWING SCALING AND MOVING</span>
  <div>
    <img id="sphere"
      style="position: relative; top: -10px; left: -10px; width: 10px; height: 15px; z-index: 1"
      src="http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/graphics/sphere.jpg" 
      border="0" alt="sphere">
  </div>
  <div>
    <img id="sphere2"
      style="position: relative; top: -10px; left: 200px; width: 10px; height: 15px; z-index: 2" 
      src="http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/graphics/sphere.jpg" 
      border="0" alt="sphere">
  </div>
  <script>
    function scaleThis() {
      if (sphere.style.pixelWidth < 900) {
        sphere.style.pixelWidth += 4;
        sphere.style.pixelHeight += 4;
        window.setTimeout(scaleThis, 1);
      }
    }

    function moveThis() {
      if (sphere.style.posLeft < 900) {
        sphere.style.posTop += 2;
        sphere.style.posLeft += 2;
        window.setTimeout(moveThis, 1);
      }
    }

    function scaleThis2() {
      if (sphere2.style.pixelWidth < 900) {
        sphere2.style.pixelWidth += 2;
        sphere2.style.pixelHeight += 2;
        window.setTimeout(scaleThis2, 1);
      }
    }

    function moveThis2() {
      if (sphere2.style.posLeft < 900) {
        sphere2.style.posTop += 1;
        sphere2.style.posLeft += 1;
        window.setTimeout(moveThis2, 1);
      }
    }
  </script>
</body>
</html>

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows 2000 Server

Header

Mshtml.h

IDL

Mshtml.idl

DLL

Mshtml.dll

See also

defaults
runtimeStyle
style
posHeight

 

 

Show:
© 2014 Microsoft