3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by jackparsana
0

What did you try? You'll need to write a small javascript thing that hides or removes the element.

1
<button id="frorm" onClick="showIt('layer1');">OPEN</button>
<script type="text/javascript">
<!--
(document.getElementById) ? dom = true : dom = false;
function hideIt(ID) {
if (dom) {document.getElementById(ID).style.visibility='hidden';}
if (document.layers) {document.layers[ID].visibility='hide';} }
function showIt(ID) {
if (dom) {document.getElementById(ID).style.visibility='visible';}
if (document.layers) {document.layers[ID].visibility='show';} }
--></script>
<div id="layer1" style="position:fixed; left:10px; z-index:10; width:50%; visibility:hidden; padding:10px; margin:10px; background:#ececec; border: 1px solid;">
<button id="form1" onclick="hideIt('layer1');">Close</button>
<br>lorem ipsum bla bla bla bla bla bla bla bla lorem ipsum bla bla bla bla bla bla bla bla bla bla bla lorem ipsum bla bla bla bla bla bla bla bla lorem ipsum bla bla bla bla bla bla bla bla lorem ipsum bla bla bla bla bla bla bla bla lorem ipsum bla bla bla bla bla bla bla bla<br>
<button id="form" onclick="hideIt('layer1');">Close</button></div>

multiple divs can be hidden.shown by their id
styling belongs in the stylesheet, this sample is not optimal

Edited by almostbob: n/a

0

I don't think you need to check for getElementByID support. I believe IE4 supported it, already.

0

the DOM you dont recognize is for early netscape & mozilla based browsers,

good practice to support everything, especially when its only a single line of conditional code
belt and braces, versions of mozilla based browsers(firefox) for linux BEOS etc do not support getelementbyid
in a few computer centuries (months), such support will be unncessary, but till everybody uses the same windows12 and ie33, , ,
its good practice to ensure compatibility with other OS/browser combinations
link <-- humor I enjoy the animation

Edited by almostbob: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.