spacer

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

home / experts / javascript / column31


Container Element Manipulation

Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans

The DIV element is the cornerstone of Dynamic HTML in Internet Explorer. The ability to contain one DIV within another DIV is a very important capability for creating dynamic effects with HTML. The canvas DIV is the container for the other two DIVs, firstPage and secondPage. The canvas DIV is static and its purpose is to define the scrolling window frame. The DIVs firstPage and secondPage are scrolling up underneath the canvas window.

A contained DIV inherits most of the properties from its containing DIV. The child DIV's top and left properties are measured with respect to the ancestor's top left corner, and both default to zero. Here is the definition of the container DIV in our scrolling box example:

function makeCanvas() {
  var text = '<DIV ID="canvas" STYLE="position:absolute">';
  text += '<DIV ID="firstPage" STYLE="position:absolute">'
   + arBody[0].innerHTML + '</DIV>';
  // (The above two lines should be joined as one line.
  // They have been split for formatting purposes.)
  text += '<DIV ID="secondPage" STYLE="position:absolute">'
   + arBody[0].innerHTML + '</DIV>';
  // (The above two lines should be joined as one line.
  // They have been split for formatting purposes.)
  text += '</DIV>';
  document.body.insertAdjacentHTML("BeforeEnd", text);
  with (canvas.style) {
	width = canvasWidth;
	height = canvasHeight;
	clip = "rect(0 " + canvasWidth + " " + canvasHeight + " 0)";
	backgroundColor = canvasColor;
  }
  canvas.style.pixelLeft = canvasLeft;
  canvas.style.pixelTop = canvasTop;
}

We first create the DIV hierarchy. The canvas DIV includes the DIVs for both firstPage and secondPage. We then insert the DIV elements into the current page, just "BeforeEnd." The function finishes with assignment of the canvas properties: its width, height, clip, background color, left position, and top position. The clip area is the only area of the DIV that is going to be displayed.

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran


The Network for Technology Professionals

Search:

About Internet.com

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

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
IBM DB2 10 for z/OS: Justifying the Upgrade · Living La Vida Colo: Choosing the Right Colocation Facility · FTC Concerns over Social Media Privacy Linger


Created: December 7, 1998
Revised: December 7, 1998

URL: http://www.webreference.com/js/column31/container.html