spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column33


Creating a Clipping Region

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

The clipping region specifies the potentially-visible area of a DHTML element. It's potentially visible, because you can turn off the visibility, thus making the clipping region invisible. Netscape Navigator and Internet Explorer have different clipping region models. Netscape Navigator uses the clip object with its width and height properties that you simply assign values to. Internet Explorer keeps the clip property as a single string that includes four numbers:

  • The x coordinate of the rectangle's left edge.
  • The x coordinate of the rectangle's right edge.
  • The y coordinate of the rectangle's bottom edge.
  • The y coordinate of the rectangle's top edge.

The function provided by DOCJSLIB defaults to a (0,0) top left corner, so the left and top edges are set at x=0 and y=0:

function docjslib_createClipRegionAt00(id, clipWidth, clipHeight) {
  if (NS4) {
    eval(id).clip.width = clipWidth;
    eval(id).clip.height = clipHeight;
  } else eval(id).style.clip = "rect(0 " + eval(clipWidth) +
    " " + eval(clipHeight) + " 0)";
  // (The above two lines should be joined as one line.
  // They have been split for formatting purposes.)
}

Setting the visibility of a DHTML element has been dealt with before in our columns. In Version 4.0 we added a function to set the visibility of an element that is passed by reference, i.e. its object is passed to the function:

function docjslib_setElementVisibility(id, flag) {
  if (NS4) {
    var str = (flag) ? 'show' : 'hide';
    eval(id).visibility = str;
  }
  else {
    var str = (flag) ? 'visible' : 'hidden';
    eval(id).style.visibility = str;
  }
}

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business


Created: January 4, 1999
Revised: December 18, 1999

URL: http://www.webreference.com/js/column33/clip.html