| | |
Hide all DIV's On Click
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2005
Posts: 1
Reputation:
Solved Threads: 0
Hello all:
I'm creating an image gallery that opens in hidden divs. Here's my javascript code:
<script type="text/javascript">
<!--
function popupSwitch(szDivID, iState)
{
if(document.layers)
{
document.layers[szDivID].visibility = iState ? "show" : "hide";
}
else if(document.getElementById)
{
var obj = document.getElementById(szDivID);
obj.style.visibility = iState ? "visible" : "hidden";
}
else if(document.all)
{
document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
}
}
// -->
</script>
If the user clicks on this link
<a href="javascript:;" onClick="popupSwitch('popup1',1);" value="Show Div"><img src="images/exterior1_th.jpg" width="127" height="89" border="0"><br>Exterior Photo One</a>
it displays this div:
<div id="popup1" class="popup">
<div align="center"><img src="images/exterior1.jpg"><br>
<b><a href="javascript:;" onClick="popupSwitch('popup1',0);" value="Hide Div"><font size="2">Close
Window [X]</font></a></b><br>
</div>
</div>
As you can see, when the user clicks "Close Window" it will hide the div.
Here's what I'm having trouble with:
if the user clicks on another link to show another DIV without closing the previous one, I need a fuction that will hide all DIV's that might be visible.
I'm a little stumped on this one. Help :-)
I'm creating an image gallery that opens in hidden divs. Here's my javascript code:
<script type="text/javascript">
<!--
function popupSwitch(szDivID, iState)
{
if(document.layers)
{
document.layers[szDivID].visibility = iState ? "show" : "hide";
}
else if(document.getElementById)
{
var obj = document.getElementById(szDivID);
obj.style.visibility = iState ? "visible" : "hidden";
}
else if(document.all)
{
document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
}
}
// -->
</script>
If the user clicks on this link
<a href="javascript:;" onClick="popupSwitch('popup1',1);" value="Show Div"><img src="images/exterior1_th.jpg" width="127" height="89" border="0"><br>Exterior Photo One</a>
it displays this div:
<div id="popup1" class="popup">
<div align="center"><img src="images/exterior1.jpg"><br>
<b><a href="javascript:;" onClick="popupSwitch('popup1',0);" value="Hide Div"><font size="2">Close
Window [X]</font></a></b><br>
</div>
</div>
As you can see, when the user clicks "Close Window" it will hide the div.
Here's what I'm having trouble with:
if the user clicks on another link to show another DIV without closing the previous one, I need a fuction that will hide all DIV's that might be visible.
I'm a little stumped on this one. Help :-)
![]() |
Similar Threads
- Spellchecker Remote (JavaScript / DHTML / AJAX)
- I hate Firefox! (JavaScript / DHTML / AJAX)
- Can anyone PLEASE help with this? (Troubleshooting Dead Machines)
- HELP lost all icons (Windows NT / 2000 / XP)
- wanna help..how to avoid default context menu (JavaScript / DHTML / AJAX)
- Folder Locking and Hiding in Windows XP (Computer Science)
- New Window (HTML and CSS)
- how to remove the system volume icon from taskbar (Windows NT / 2000 / XP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Javascript, Form fields validation and submit
- Next Thread: Dynamically modifying the CSS attributes through Javascript
| Thread Tools | Search this Thread |
ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically beta box browser bug calendar captchaformproblem checkbox child close column createrange() css cursor date debugger dependent disablefirebug dom download dropdown editor element embed engine error events explorer ext file form forms getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe images internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jump libcurl math media microsoft mimic object onmouseoutdivproblem onreadystatechange parent paypal pdf php player position post problem programming progressbar regex runtime scriptlets scroll search security select shopping size software sql text textarea unicode w3c web website window windowofwords windowsxp wysiwyg \n






