Re: Javascript toggles div visibility, img elements dissappear
- From: "dwilson" <slipperydan5@xxxxxxxxx>
- Date: 7 Dec 2005 09:17:10 -0800
So I have tried your suggestion, and even went so far as to remove the
anchor tag and use the onclick event directly on the img itself. I am
getting the same behavior, and not only with images but with a table as
well. I guess my question is how can I call this javascript without the
browser being in a state that will not reflect/redraw these elements?
The code...
<html>
<head>
<title>Expand Tree</title>
<script LANGUAGE="JavaScript">
function splodeDiv(divRef, imgRef){
var theDiv = document.getElementById(divRef);
var theImg = document.getElementById(imgRef);
var divState = theDiv.style.visibility == "hidden";
theDiv.style.visibility = divState ? "visible" : "hidden";
theDiv.style.position = divState ? "relative" : "absolute";
theImg.src = divState ? "minus.gif" : "plus.gif";
}
function load(){
var allImgs = document.getElementsByTagName('img');
for(var i = 0; i < allImgs.length; i++){
if(allImgs[i].id.search('expandRetract' != -1)){
allImgs[i].src = "minus.gif";
}
}
var allDivs = document.getElementsByTagName('div');
for(var i = 0; i < allDivs.length; i++){
if(allDivs[i].id.search('folderGroup' != -1)){
allDivs[i].style.visibility = "visible";
allDivs[i].style.position = "relative";
}
}
}
</script>
</head>
<body onload="javascript:load();">
<img id="expandRetract1" src="minus.gif" onclick="splodeDiv('folder
Group1', 'expandRetract1');return false;">
<div id="folder Group1">
Howdy!
<img src="minus.gif">
<table border="1">
<tr>
<td>
in the table
</td>
</tr>
</table>
</div>
</body>
</html>
Thanks.
Dan Wilson
.
- Follow-Ups:
- Re: Javascript toggles div visibility, img elements dissappear
- From: Richard Cornford
- Re: Javascript toggles div visibility, img elements dissappear
- References:
- Javascript toggles div visibility, img elements dissappear
- From: dwilson
- Re: Javascript toggles div visibility, img elements dissappear
- From: Richard Cornford
- Javascript toggles div visibility, img elements dissappear
- Prev by Date: Re: Problem with Type-Ahead
- Next by Date: detecting cookieless sessions
- Previous by thread: Re: Javascript toggles div visibility, img elements dissappear
- Next by thread: Re: Javascript toggles div visibility, img elements dissappear
- Index(es):
Relevant Pages
|