Hi Shane,
Your (document.layers) expression will only return true for Netscape and
Firefox because HTML layers was a Netscape thing. MSIE never implemented
Layers.
Therefore null is what you'll get when testing with MSIE.
But document.getElementById is supported by nearly all modern browser, so
just do something like the following:
var myObject = document.getElementById('myObject');
myObject.style.visibility = 'visible';
But then the visibility attribute is not supported by all, so just use
display, something like:
var myObject = document.getElementById('myObject');
myObject.style.display = 'block'; // or 'none' for hidden
Hope that is what you're looking for.
~ Scott Cadillac
~ 403-254-5002
~ [EMAIL PROTECTED]
~ Custom Software for Business
http://custom.softwarefor.net
~ The XML-Extranet Partnership
~ P.O. Box 69006
RPO Bridlewood SW
Calgary, Alberta
Canada T2Y 4T9
> -----Original Message-----
> From: Shane Pearlman [mailto:[EMAIL PROTECTED]
> Sent: Monday, August 22, 2005 1:07 PM
> To: [email protected]
> Subject: Witango-Talk: JS $%^%^ Browser issue
>
> Two questions:
>
>
>
> 1. Is there a way in Witango to get the users browser and
> store it in a Witango var before processing the code -
> something like USER_AGENT?
>
>
>
> 2. This should be the most basic thing and yet I can't seem
> to get it to behave. IE refuses to create a layer object and
> let me reference it. Says it is null and void.
>
>
>
> Works fine in Firefox/Netscape
>
>
>
> Eval() statement fails in IE .. browser complains stating the
> expression return undefined or null as if the layer doesn't
> exist. Can anyone see off hand what I am missing?
>
>
>
> I even tried a direct command and it fails -
> document.all['Custom'].style.visibility = "visible";
>
>
>
> Same error!
>
>
>
> WTF!?! =)
>
>
>
> I dumped a bunch of the code below:
>
>
>
> [JS Header Code]
>
>
>
> <!--
>
> if (document.layers){
>
> //Netscape 4 specific code
>
> pre = 'document.';
>
> post = '';
>
> }
>
> if (document.getElementById){
>
> //Netscape & Firefox specific code
>
> pre = 'document.getElementById("';
>
> post = '").style';
>
> }
>
> if (document.all){
>
> //IE specific code
>
> pre = 'document.all.';
>
> post = '.style';
>
> }
>
>
>
> var currentLayer = 'Custom';
>
>
>
> function showLayer(layer){
>
> eval(pre + currentLayer +
> post).visibility = 'hidden';
>
> eval(pre + layer + post).visibility
> = 'visible';
>
> currentLayer = layer;
>
> }
>
>
>
>
>
>
>
> Second option was: (made no difference)
>
>
>
> if (document.all){
>
> //IE4+ specific code
>
> pre = 'document.all[';
>
> post = '].style';
>
> }
>
>
>
>
>
>
>
> [Body Code]
>
>
>
>
>
> <script language="javascript">
>
> if (navigator.appName == "Netscape")
>
> {
>
> document.write('<table border=0 cellspacing=0
> cellpadding=0 width=509 height=23><tr><td height=23><div
> id="SubMenu"><div id="Custom"><img
> src="files/Sub_Menu_Custom.gif" width=509 height=23 border=0
> name="Custom"></div><div id="Tiara"><img
> src="files/Sub_Menu_Tiara.gif" width=509 height=23 border=0
> name="Tiara"></div><div id="Repair"><img
> src="files/Sub_Menu_Repair.gif" width=509 height=23 border=0
> name="Repair"></div><div id="About"><img
> src="files/Sub_Menu_About.gif" width=509 height=23 border=0
> name="About"></div></div></td></tr></table>')
>
> }
>
> else
>
> {
>
> document.write('<table border=0 cellspacing=0
> cellpadding=0 width=509 height=34><tr><td height=7><img
> src="files/Blank_Spacer.gif" width=509 height=7
> border=0></td></tr><tr><td height=23><div id="SubMenu"><div
> id="Custom"><img src="files/Sub_Menu_Custom.gif" width=509
> height=23 border=0 name="Custom"></div><div id="Tiara"><img
> src="files/Sub_Menu_Tiara.gif" width=509 height=23 border=0
> name="Tiara"></div><div id="Repair"><img
> src="files/Sub_Menu_Repair.gif" width=509 height=23 border=0
> name="Repair"></div><div id="About"><img
> src="files/Sub_Menu_About.gif" width=509 height=23 border=0
> name="About"></div></div></td></tr><tr><td height=6><img
> src="files/Blank_Spacer.gif" width=509 height=6
> border=0></td></tr></table>')
>
> }
>
> </script>
>
> -->
>
>
> ______________________________________________________________
> __________
> TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
>
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf