hiding a DIV in another frame . . .

A

Anonymous

Guest
Hi

how can I hide a DIV in another frame by JavaScript ?
 
Example:
Code:
<div name="mdiv">whatever</div>
If you want it always hidden you can make a style for it:
Code:
.invisible {
	display: none;
}

// And then...

<div name="mdiv" class="invisible">whatever</div>
Or just using:
Code:
<div style="display: none;">whatever</div>
If you want to hide and show it, with javascript, you can do:
Code:
<script type="text/javascript" language="javascript">

function HideShow() {
   mydiv = document.getElementById('mdiv').style.display;
   if(mydiv == 'none'){
       mydiv = '';
   }
   else{
       mydiv = 'none';
   }
}

// So, calling this function will hide and show it depending on its status
// Not sure, but i think it will work :p

</script>
 
Well the correct cide is :

Code:
<script type="text/javascript" language="javascript">
function HideShow() {
    if (document.getElementById('mdiv').style.display == 'none')
    {
      document.getElementById('mdiv').style.display = '';
    } else
    {
      document.getElementById('mdiv').style.display = 'none';
    }
}   
</script>

and we have to set ID (not name) in DIV if we wanna use getElementById , like this :

Code:
<div id="mdiv">whatever</div>


by the way Ive found my answer ,
we can call our function from other frame like this (main is the name of our frame):

Code:
parent.main.HideShow()

thanx a lot for giving me the tip , because your idea gave me
how to make this code works :) it was helpful and I appreciate that

Cheers
 
That was just an example. I actually use the tag's name and id at the same time regarding old browsers and/or its incompatibility.
Code:
parent.main.HideShow()
Yep, you can also call it e.g.: on the body's onload or something!

Cheers
 
Back
Top