By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,599 Members | 1,872 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,599 IT Pros & Developers. It's quick & easy.

Figuring out Hide/Unhide mode, in IE and Mozilla

P: n/a
Hello all,

I'm a php developer. I have been using a very simple script to
hide/unhide divs in my script:

function DisplayI(obj)
{
obj.style.display=("none"==obj.style.display? "block" : "none");
}

the Div tag, looks like this:
<div id="blabla" style='display:hidden;'>

the ID of the Div is being compiled by a php script linked to a
Database (therefore, all DIVs get different ids).

It works perfectly in I.E, but in mozilla (firefox and netscape) it
doesn't.
If I change "display:hidden" to "display:block", it shows them open
completely (without hiding) throughout mozilla and I.E together.

I'm looking for a script that hide and unhides my divs and works in a
crossbrowser environment.
I've seen codes to solve the crossbrowser thing, but all of them
seperated "hidediv" and "showdiv" to two functions, and I need them
unified - the code to figure out if the div is shown and hide it, and
the other way around.

Can anyone please help me with this?
Thanks a lot!

~mooey

Sep 26 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On 26 Sep 2005 00:41:24 -0700, mooeypoo wrote:
function DisplayI(obj)
{
obj.style.display=("none"==obj.style.display? "block" : "none"); ^^^^ }

the Div tag, looks like this:
<div id="blabla" style='display:hidden;'>


<div id="blabla" style='display:none'>

"hidden" is value of visibility style's attribute.

--
~ "FINARMENTE LI SFRATTATI AVRANNO UN TETTO SULLA TESTA!
....però tirato ammodino, un tegolo pe' vorta.." (Il vernacoliere)

Sep 26 '05 #2

P: n/a
mooeypoo wrote:
Hello all,

I'm a php developer. I have been using a very simple script to
hide/unhide divs in my script:

function DisplayI(obj)
{
obj.style.display=("none"==obj.style.display? "block" : "none");
}

the Div tag, looks like this:
<div id="blabla" style='display:hidden;'>


<div id="blabla" style='display:none;'> // note "display" property.
function DisplayI(id){
var obj;
if(obj=document.getElementById(id)){
obj.style.display=("none"==obj.style.display?"":"n one");
return;
}
//if you arrive here, obj doesn't exist.
}

[snip]
Mick
Sep 26 '05 #3

P: n/a
I have done all of that (changed display to none, and tried your code)
but now it doesnt' work in I.E aswell :( won't open my divs.

It doesn't even show an error, it just doesn't show my div in I.E or
Mozilla Firefox.

Ideas? :(

Thanks !

~mooey

Sep 26 '05 #4

P: n/a
ASM
mooeypoo a écrit :
I have done all of that (changed display to none, and tried your code)
but now it doesnt' work in I.E aswell :( won't open my divs.

It doesn't even show an error, it just doesn't show my div in I.E or
Mozilla Firefox.

Ideas? :(


re strat from beginning ...

<html>
<p><button onclick="mooey('poo');">yes no</button>
<div id="poo" style="display: none;height:150px;">
<h1>it is not a good idea</h1>
<p>Why ?
<p>Because without JS you'll can never see this div ...
</div>
<h2> Oh what a so terrific YoYo effect !</h2>

<script type="text/javascript">
function mooey(aDiv) {
var D = document.getElementById(aDiv).style;
D.display = D.display==''? 'none' : '';
}
</script>
</html>

--
Stephane Moriaux et son [moins] vieux Mac
Sep 26 '05 #5

P: n/a
Stephane,

thanks, but it still doesn't work in Firefox. :(

~mooey

Sep 28 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.