Well, it's checking the default image (collapse.gif) to see if it's there (which it will be when the page is first loaded). So, if the user has scripts enabled, it changes to the image to expand.gif and collapses all of the divs - so that the expandable tree is in a fully collapsed state to start. But if the user is does not have scripts enabled, nothing happens and the collapse.gif remains with the fully expanded tree.
I have a...
User Profile
Collapse
-
Dormilich, you rock!
Thanks a lot - it's working great now. The page is working with or without scripts enabled. I knew it was something simple that I wasn't doing (or doing wrong). I didn't use the else if toggle, as it wasn't needed.
Your help is MUCH appreciated!
Thanks again!
UberGirlLeave a comment:
-
Okay - well thanks! So, here's what's not working...
This function is being called onload:
Code:function ToggleDivImage() { var boxes = document.getElementsByTagName("img"); for(var i=0;i<boxes.length;i++) if(boxes[i].className.match("ti")) toggleimage(boxes[i]); }
Which calls this one:
...Code:function toggleimage(elem) {Leave a comment:
-
But my problem is that the default values (i.e. if the user has scripts disabled) needs to be the collapse image, which matches the default value of the expanded divs.
I thought you said I shouldn't do it onload because the page hasn't loaded yet?? I've tried the onload, and, like I said, the variable gets swapped appropriately but it doesn't show up on the page correctly. I figured there was just something I was missing to apply...Leave a comment:
-
okay - I think I understand. so I need to try to swap them after they load - which would mean calling a script after that point in the body or at the end of the body? sorry - I really am new at this.Leave a comment:
-
Anyone have any ideas on what I need to do to get the image swapped from collapse to expand during body onload?Leave a comment:
-
hide is working, but changing image is not
I ended up using the code below, calling HideDiv and ToggleDivImage onload, but only hiding the divs on load (function toggledisplay) is working. The function toggleimage isn't, though the alerts I put in place verify that the variable "image" ends up getting changed from collapse.gif to expand.gif. Yet the result isn't reflected on the page (i.e. collapse.gif still shows)....Leave a comment:
-
Thanks, Dormilich.
I was able to search out some examples using className and I got it to work.Leave a comment:
-
noscript, onload or something else?
Hi,
I'm a novice... just trying figure out something simple, I'm sure.
I've got a script within my <head> tags to show/hide divs on click:
...Code:function showHide(divID, imgID){ if (document.getElementById(divID).style.display == "none") { document.getElementById(divID).style.display = "block"; document.getElementById(imgID).src = "http://bytes.com/images/collapse.gif";
No activity results to display
Show More
Leave a comment: