Click to See Complete Forum and Search --> : Browser Redirection


doobster
05-04-2003, 07:35 AM
Hello, I am having problems trying to show and a div class in Netscape 6 and above, everything works fine in IE.

This is the code I am using.


// quick browser tests
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;

function show(sw,obj) {
// show/hide the divisions
if (sw && (ie4 || ie5) ) document.all[obj].style.visibility = 'visible';
if (!sw && (ie4 || ie5) ) document.all[obj].style.visibility = 'hidden';
if (sw && ns4) document.layers[obj].visibility = 'visible';
if (!sw && ns4) document.layers[obj].visibility = 'hidden';
}


I call the function "show" when I want the class to either hide or unhide. But it does not unhide in Netscape 6 and above.

khalidali63
05-04-2003, 09:04 AM
I hope I have not missed anything..but
you have a condition to validate that if the broiwsers is NS version 6+
var ns6 =......

however in the hide/show code you do not have any code referenciing that if its hiding or showing

if (sw && ns6) document.layers[obj].visibility = 'visible';

And by the way for ns4 visibility will be
"show"
and
"hide"

doobster
05-04-2003, 03:20 PM
Hi there, I have realized my flaws in my previous post and have updated my code. However, I am still having problems with AOL 8.0 browser (I know many don't like it, but I must accomidate my members) and I am not sure if it works in Opera or any other browser.

This is my code now


var isDOM=false;
var isNS=false;
var isIE=false;

if (document.getElementById) isDOM=true;
if (document.layers) isNS=true;
if (document.all) isIE=true;

function getObject(id) {
var object = null;
if (isDOM) object=document.getElementById(id);
else {
var obj;
if (isNS) obj="document."+id;
else if (isIE) obj=id+".style";
object=eval(obj);
}
return object;
}

function hideIt(id) {
var object=getObject(id);
if (isNS) object.visibility="hide";
else if (isDOM || isIE) object.visibility="hidden";
}

function showIt(id) {
var object=getObject(id);
if (isDOM) object.style.visibility="visible";
else if (isNS) object.visibility="show";
else if (isIE) object.visibility="visible";
}


This code works perfectly in IE and Netscape browsers. Any help to get it to work in AOL, Opera and other browsers would be appreciated.

doobster
05-05-2003, 10:28 AM
Hello, I just wanted to update and ask for more help.

The above code appears not to work on Mac OS'. If anyone knows a solution to my problem please post it as it would be greatly appreciated.