< Script >
// Check for IE
var ns4 = (document.layers) ? true : false;
var ie4 = (document.all && !document.getElementById) ? true : false;
var ie5 = (document.all && document.getElementById) ? true : false;
var ns6 = (!document.all && document.getElementById) ? true : false;
function show(sw,obj)
{
if (sw && (ie4 ie5) ) document.all[obj].style.visibility = 'visible';
if (!sw && (ie4 ie5) ) document.all[obj].style.visibility = 'hidden';
if (sw && ns4) document.layers[obj].visibility = 'visible';
if (!sw && ns4) document.layers[obj].visibility = 'hidden';
}
< /script >
Copy paste this code in between < Head > < /Head > tags.
How to use?
Here i am giving a simple example how to use it in your HTML (Script) code.
< div id="myLayersDiv" align="center" > Here is your control. < /div >
Now we want to hide the "myLayersDiv" element from the HTML page at runtime using JavaScript.
< type="button" value="Show" onclick="show(false,'myLayersDiv');" />
< type="button" value="Hide" onclick="show(false,'myLayersDiv');" />
When you click on button OnClick event get fired the it automaticaaly calls the function assigned by you to the property of the button control that is OnClick this contain show( bool, srcID);
where:
Bool : is true, false identify show or hide the control.
srcID: it specifies the control, you want to hide.
Try out, according to your need.
It works fine when i try. Just make some modification according to your need and enjoy the solution.