Waldo2k2
September 13th, 2002, 04:42 PM
I'm working with the visibility of divs. I've tried to come up with a generic function i can pass the name of a div to. Basically the function should show that div (visibility=visible) and hide the one that was visible (it's saved in a variable;visiblility=hidden). I think i've worked out syntax bugs...and sort of made it cross browser to an extent, but I'm having trouble with "a required object". Here's the script and implementation:
var toThis;
var wasThis="null";
var theDiv;
function switchTo(toThis)
{
if (document.all)
{
theDiv=document.all(toThis).style;
}
else if (document.GetElementById)
{
theDiv=document.GetElementById(toThis).style;
}
theDiv.visibility="visible";
if (wasThis!="null")
{
wasThis.visibility="hidden";
}
wasThis=theDiv;
}
...
<div id="aboutMe">
This is info about Me
</div>
<div id="aboutSchool">
This is info about the school
</div>
<a href="#" class="barlink" onclick="javascript:switchTo(aboutMe); return false;">
About Me
</a>
<br>
<a href="#" class="barlink" onclick="javascript:switchTo(aboutSchool); return false;">
About School
</a>
i've also attached the whole source in .txt format
thanks for any help you can give me
var toThis;
var wasThis="null";
var theDiv;
function switchTo(toThis)
{
if (document.all)
{
theDiv=document.all(toThis).style;
}
else if (document.GetElementById)
{
theDiv=document.GetElementById(toThis).style;
}
theDiv.visibility="visible";
if (wasThis!="null")
{
wasThis.visibility="hidden";
}
wasThis=theDiv;
}
...
<div id="aboutMe">
This is info about Me
</div>
<div id="aboutSchool">
This is info about the school
</div>
<a href="#" class="barlink" onclick="javascript:switchTo(aboutMe); return false;">
About Me
</a>
<br>
<a href="#" class="barlink" onclick="javascript:switchTo(aboutSchool); return false;">
About School
</a>
i've also attached the whole source in .txt format
thanks for any help you can give me