Show and hide divs in FireFox

J

JonBosker

Hi I have a little script that works well in IE but not in FireFox

function DivExpand(obj, setting)
{
if ((setting == 'hide') || ((setting == 'swap') &&
(document.all[obj].style.display == 'block')))
document.all[obj].style.display = 'none';
else
document.all[obj].style.display = 'block';
}

can anyone please tell me what I have to change for FireFox?

And would this test do the trick?
var ns4 = (document.layers) ? true : false;
var ie4 = (document.all && !document.getElementById) ? true : false;
var ie5 = (document.all && document.getElementById) ? true : false;
var ns6 = (!document.all && document.getElementById) ? true : false;

Thanks in advance. Jon.
 
L

-Lost

Hi I have a little script that works well in IE but not in FireFox

function DivExpand(obj, setting)
{
if ((setting == 'hide') || ((setting == 'swap') &&
(document.all[obj].style.display == 'block')))
document.all[obj].style.display = 'none';
else
document.all[obj].style.display = 'block';
}

can anyone please tell me what I have to change for FireFox?
document.getElementById(obj).style.display

And would this test do the trick?
var ns4 = (document.layers) ? true : false;
var ie4 = (document.all && !document.getElementById) ? true : false;
var ie5 = (document.all && document.getElementById) ? true : false;
var ns6 = (!document.all && document.getElementById) ? true : false;

You should *never* browser detect. Instead, those variables should reflect levels of
functionality. Or simply, feature detect as you go along.

-Lost
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top