September 3, 2000 - Removing Objects without Reflowing | WebReference

September 3, 2000 - Removing Objects without Reflowing

Yehuda Shiran September 3, 2000
Removing Object without Reflowing
Tips: September 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

While setting the display property to none removes the paragraph and reclaims the empty space, turning the visibility property on and off just makes the paragraph transparent, without reflowing the page. Clicking the following link will turn off and on the visibility of the first paragraph:

Click here to remove or bring back the first paragraph below:

Mouse over this paragraph and see how the font size changes to size 30. Mouse out and see it go down to 8. This is a good way to pack more text on a window-size page and let the user magnify the paragraph currently being read. See how the browser reflows the page as if this paragraph was originally written with the current font size. Mouse over this paragraph and see how the font family changes to size Courier. Mouse out and see it changing to Arial. This is a good way to emphasize the paragraph currently being read. See how the browser reflows the page as if this paragraph was originally written with the current font family. We defined the link above as follows:

<SPAN STYLE="cursor: hand; color: tan" onClick="disappear(fontPar)">Click here to remove or 
  bring back the first paragraph below:</SPAN>

where the function disappear() is defined as:

function disappear(obj) {
  if (obj.style.visibility == "hidden") {
    obj.style.visibility = "visible";
  }
  else {
    obj.style.visibility = "hidden";
  }
}