473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Firefox won't work with show/hide div script

1
This code works fine in IE, but doesn't do anything in Firefox. Is there an issue with the layer_ref?
If you could re-write this to make it work, I would love you for it!
Expand|Select|Wrap|Line Numbers
  1. <!-- Start Show / Hide Div Script -->
  2. <script language="javascript">
  3.         <!--
  4.         var state = 'none';
  5.  
  6.         function showhide(layer_ref) {
  7.  
  8.         if (state == 'block') {
  9.         state = 'none';
  10.         }
  11.         else {
  12.         state = 'block';
  13.         }
  14.         if (document.all) { //IS IE 4 or 5 (or 6 beta)
  15.         eval( "document.all." + layer_ref + ".style.display = state");
  16.         }
  17.         if (document.layers) { //IS NETSCAPE 4 or below
  18.         document.layers[layer_ref].display == state;
  19.         }
  20.         if (document.getElementById && !document.all) {
  21.         maxwell_smart = document.getElementById(layer_ref);
  22.         maxwell_smart.style.display == state;
  23.         }
  24.         }
  25.         //-->
  26. </script>
  27. <!-- End Show / Hide Div Script -->
  28.  
Mar 5 '07 #1
3 4880
iam_clint
1,208 Expert 1GB
document.all (not supported by most browsers)

use document.getElementById()
Mar 5 '07 #2
acoder
16,027 Expert Mod 8TB
Also, the line
Expand|Select|Wrap|Line Numbers
  1. maxwell_smart.style.display == state;
should be
Expand|Select|Wrap|Line Numbers
  1. maxwell_smart.style.display = state;
You are comparing instead of setting.
Mar 5 '07 #3
sumittyagi
202 Expert 100+
also:
eval( "document.all." + layer_ref + ".style.display = state");

should be:
eval("document.all." + layer_ref + ".style.display = " + state);

//but use document.getElementById(layer_ref).style.display = state; instead

//document.all is supported in firefox, but it is depricated, i.e. a warning message is shown.
but document.getElementById is supported in almost all the browsers.
Mar 6 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Jeremy Epstein | last post by:
Hi guys, I've got a page that shows a number of packages available for sale. Each package has a little description, and then a (sometimes long) list of features for each package. I thought it...
5
by: hibernate | last post by:
I'm somewhat new to javascript/DHTML, and this problem has been plaguing me. I have made an 'array' of <div> tags within my html document like so: <div id="menu"> menu1 </div> <div id="menu">...
4
by: Gregor | last post by:
I am trying to use an image map with a mouseover function to show various DIV tags. I am not an expert, but what I've come up with works in IE but not in FireFox. Any insight would be greatly...
4
by: drew197 | last post by:
I am a newbie. I am editing someone elses code to make it compatible with Firefox and Safari. In IE, when you click on the proper link, a block of text is shown in a nice paragraph form. But, in...
2
by: reynoldlariza | last post by:
Can somebody please help me, i tried playing around with IE6 and Firefox 2.0 browser for setting zIndexes and hide & show of divs. It seems to work to both. I tried repeatedly clicking on different...
4
by: badaczewski | last post by:
The following javascript appears on a popup window. <script language="javascript" type="text/javascript"> function InsertContact(value) { window.opener.CallBackContact(value); window.close();...
1
by: reemamg | last post by:
I've two frames in a page. On the left Frame i've buttons , if we click on button the particular pages will be loaded in the middle Frame. This code works perfectly in Firefox but not in IE ... ...
7
by: hollopeterb | last post by:
my javascript code works great in IE but not in Firefox, can anyone help? Thanks!! Here is the code: <script type="text/javascript"> <!-- function MM_findObj(n, d) { //v3.0 var p,i,x; if(!d)...
1
oranoos3000
by: oranoos3000 | last post by:
hi would you please help me i have a online shopping center that i show pictures of the my product in home page. in the InterExplorer pictures is shown correctly but in Firefox browser is shown...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.