473,557 Members | 2,814 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Firefox 2.0 problem with Javascript

12 New Member
hi all,

i do the following JS code:

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript"> 
  2.  
  3. function hideLevel(id) { 
  4. var thisLevel = document.getElementById(id); 
  5. thisLevel.style.display = "none"; 
  6.  
  7. function showLevel(id) { 
  8. var thisLevel = document.getElementById(id); 
  9. if ( thisLevel.style.display == "none") { 
  10. thisLevel.style.display = "block"; 
  11. else { 
  12. hideLevel(id); 
  13.  
  14. function hideAll() { 
  15. hideLevel("layer1"); 
  16. hideLevel("layer2"); 
  17. hideLevel("layer3"); 
  18.  
  19. </script> 
  20.  
as you see, when i click on some link - the div layer is showing, when i click back - it is hiding.

Firefox is showing nothing. When I click on the link it shows for a milli-second, then disappears.

What can You suggest, please?
Apr 19 '07 #1
14 5535
mrhoo
428 Contributor
All I see that is wrong is your script type.
<script language="javas cript">

Should be <script type="text/javascript">
IE doesn't care, because it uses jscript, but some other browsers need the
correct type
Apr 19 '07 #2
Romulo NF
54 New Member
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2.  
  3. <html>
  4. <head>
  5.     <title>Untitled</title>
  6. </head>
  7.  
  8. <style>
  9. .box {width:50px; height:50px; border:1px solid #000}
  10. </style>
  11.  
  12. <script> 
  13.  
  14. function hideLevel(id) { 
  15. var thisLevel = document.getElementById(id); 
  16. thisLevel.style.display = "none"; 
  17.  
  18. function showLevel(id) { 
  19. var thisLevel = document.getElementById(id); 
  20. if ( thisLevel.style.display == "none") { 
  21. thisLevel.style.display = "block"; 
  22. else { 
  23. hideLevel(id); 
  24.  
  25. function hideAll() { 
  26. hideLevel("layer1"); 
  27. hideLevel("layer2"); 
  28. hideLevel("layer3"); 
  29.  
  30. </script> 
  31.  
  32. <body>
  33.  
  34. <div class="box" id="layer1"></div>
  35. <div class="box" id="layer2"></div>
  36. <div class="box" id="layer3"></div>
  37.  
  38. <a href="javascript:void(0)" onclick="hideAll()">Hide all</a>
  39. <a href="javascript:void(0)" onclick="hideLevel('layer1')">Hide 1</a>
  40. <a href="javascript:void(0)" onclick="hideLevel('layer2')">Hide 2</a>
  41. <a href="javascript:void(0)" onclick="hideLevel('layer3')">Hide 3</a>
  42. <a href="javascript:void(0)" onclick="showLevel('layer1')">Show 1</a>
  43. <a href="javascript:void(0)" onclick="showLevel('layer2')">Show 2</a>
  44. <a href="javascript:void(0)" onclick="showLevel('layer3')">Show 3</a>
  45.  
  46. </body>
  47. </html>
  48.  
  49.  
everything worked just fine for me!
Apr 19 '07 #3
blobb
12 New Member
here is my complete code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. ok. here is the complete code:
  3.  
  4. -------------------------------------------------------------------
  5. <html>
  6.  
  7. <head>
  8.  
  9. <script language=javascript type='text/javascript'>
  10.  
  11. function hideDiv() 
  12.  
  13. {
  14. if (document.getElementById) { // DOM3 = IE5, NS6 
  15. document.getElementById('hideShow').style.visibility = 'hidden';
  16. else { 
  17. if (document.layers) { // Netscape 4 
  18. document.hideShow.visibility = 'hidden'; 
  19. else { // IE 4 
  20. document.all.hideShow.style.visibility = 'hidden'; 
  21.  
  22. function showDiv() { 
  23. if (document.getElementById) { // DOM3 = IE5, NS6 
  24. document.getElementById('hideShow').style.visibility = 'visible'; 
  25. else { 
  26. if (document.layers) { // Netscape 4
  27. document.hideShow.visibility = 'visible';
  28. }
  29. else { // IE 4
  30. document.all.hideShow.style.visibility = 'visible';
  31. }
  32. }
  33. }
  34. </script>
  35.  
  36. <body onLoad = "javascript:hideDiv();">
  37.  
  38. <div>
  39.  
  40. <a href onClick="showDiv('hideShow');" style="cursor: hand">
  41. <img src = "file://D:/webroot/site_pics/bo.jpg"></a>
  42. </div>
  43.  
  44. <div id="hideShow">
  45. <img src = "file://D:/webroot/site_pics/bo_big.jpg" onClick = "hideDiv('hideShow');">
  46. </div>
  47.  
  48. </body>
  49. </html>
  50.  
  51. ---------------------------------------------------------------- 

interesting thing is that i have tried it without images, just with simple text - AND IT WORKS!
and when I insert images - no result.
Apr 20 '07 #4
drhowarddrfine
7,435 Recognized Expert Expert
This won't work:
<a href onClick="showDi v('hideShow');" style="cursor: hand">
The href isn't equal to anything. Also, change onClick to lower case.
In addition, 'hand' is not standard and IE only.

Other points:
1) I assume you are using a valid doctype? You will never get IE to pretend it's a modern browser without one.

You still need to change to this:
<script type="text/javascript">
Apr 20 '07 #5
acoder
16,027 Recognized Expert Moderator MVP
interesting thing is that i have tried it without images, just with simple text - AND IT WORKS!
and when I insert images - no result.
That means it does work.

Firefox will not let you access local files using Javascript whilst IE does.

I'm afraid the only solution is to use web images, not images from your hard drive.

Even so, you should correct your errors as drhowarddrfine pointed out.
Apr 20 '07 #6
blobb
12 New Member
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2.  
  3. <html>
  4. <head>
  5.     <title>Untitled</title>
  6. </head>
  7.  
  8. <style>
  9. .box {width:50px; height:50px; border:1px solid #000}
  10. </style>
  11.  
  12. <script> 
  13.  
  14. function hideLevel(id) { 
  15. var thisLevel = document.getElementById(id); 
  16. thisLevel.style.display = "none"; 
  17.  
  18. function showLevel(id) { 
  19. var thisLevel = document.getElementById(id); 
  20. if ( thisLevel.style.display == "none") { 
  21. thisLevel.style.display = "block"; 
  22. else { 
  23. hideLevel(id); 
  24.  
  25. function hideAll() { 
  26. hideLevel("layer1"); 
  27. hideLevel("layer2"); 
  28. hideLevel("layer3"); 
  29.  
  30. </script> 
  31.  
  32. <body>
  33.  
  34. <div class="box" id="layer1"></div>
  35. <div class="box" id="layer2"></div>
  36. <div class="box" id="layer3"></div>
  37.  
  38. <a href="javascript:void(0)" onclick="hideAll()">Hide all</a>
  39. <a href="javascript:void(0)" onclick="hideLevel('layer1')">Hide 1</a>
  40. <a href="javascript:void(0)" onclick="hideLevel('layer2')">Hide 2</a>
  41. <a href="javascript:void(0)" onclick="hideLevel('layer3')">Hide 3</a>
  42. <a href="javascript:void(0)" onclick="showLevel('layer1')">Show 1</a>
  43. <a href="javascript:void(0)" onclick="showLevel('layer2')">Show 2</a>
  44. <a href="javascript:void(0)" onclick="showLevel('layer3')">Show 3</a>
  45.  
  46. </body>
  47. </html>
  48.  
  49.  
everything worked just fine for me!
yes. this helped, thanks a lot, man!
as i understood, the problem was "javascript:voi d(0)" - i removed it once from the code, and my problem repeated.
Apr 21 '07 #7
drhowarddrfine
7,435 Recognized Expert Expert
btw, your doctype is incomplete and puts IE into quirks mode. New pages should always use the strict doctype, too. Use this one:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
Apr 21 '07 #8
blobb
12 New Member
btw, your doctype is incomplete and puts IE into quirks mode. New pages should always use the strict doctype, too. Use this one:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

i will use

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">

is this ok? cuz in strict i some table problems on the page...
Apr 21 '07 #9
drhowarddrfine
7,435 Recognized Expert Expert
Are transitioning older, deprecated code? Otherwise, fix your tables and use strict.
Apr 21 '07 #10

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

Similar topics

12
1925
by: Howard Kaikow | last post by:
Yesterday, I decided to try Firefox. I've encountered a behavior that is either a bug in Firefox or a bug in my Javascript code. I'll try to explain the problem, hoping that this newsgroup can (in)validate my Javascript code. First, I'll describe the purpose of the Javascript code. I often have a need to post a URL to something at my own...
2
1450
by: Stewart | last post by:
Originally posted in comp.lang.javascript: Newsgroups: comp.lang.javascript From: "Stewart" Date: 23 Aug 2005 02:50:04 -0700 Local: Tues, Aug 23 2005 10:50 am Subject: FireFox, RemoveChild, AppendChild, making width grow? Hi,
3
2950
by: niconedz | last post by:
Hi The following code works fine in IE but not Firefox. It's a little script that zooms an image and resizes the window to fit. Can anybody tell me what's wrong? Thanks Nico == btw.. sorry for the long post ==
45
4676
by: Pat | last post by:
its seems asp.net validation doesn't fire when using FireFox? Tested a page and it doesn't fire. It seems the javascript doesn't fire Any ideas?
6
14437
by: Mark Olbert | last post by:
The doPostBack javascript functioning is not submitting the page when called by linkbuttons (or an autopostback checkbox, for that matter). I'm aware of a problem with Netscape browsers and the postback code, but I have a workaround for that installed (and it looks like the code generated by ASP.NET when it renders the page does the same...
4
2150
by: petermichaux | last post by:
Hi, I'm hoping for a reason I'm wrong or an alternate solution... I'd like to be able to dynamically include some javascript files. This is like scriptaculous.js library but their solution is broken in Firefox 1.5.0.1 on OS X. What happens with the Scriptaculous library is this In the html document the author only has to include one...
4
2318
by: lmarceglia | last post by:
Hi, I have this website that doesn't work in Firefox 1.5: www.pianetaluca.com The HTML source is: <TITLE>PianetaLuca</TITLE> </HEAD>
11
3420
by: minnesotti | last post by:
Hi there, I subscribed to a photographic pictures-hosting website which is heavy on JavaScript. My preferred latest browser Mozilla Firefox does not work with it -- no pictures are displayed and no buttons react to clicking. The website's helpdesk says it should work with Firefox, and could not offer any more advices. The JavaScript Console...
8
1917
by: Matt Kruse | last post by:
http://news.zdnet.com/2100-1009_22-6121608.html Hackers claim zero-day flaw in Firefox 09 / 30 / 06 | By Joris Evers SAN DIEGO--The open-source Firefox Web browser is critically flawed in the way it handles JavaScript, two hackers said Saturday afternoon. An attacker could commandeer a computer running the browser simply by crafting...
3
2416
by: SAL | last post by:
Hello, I did google this issue and found some stuff related to BrowserCaps section of either web.config or machine.config but it didn't work. It seems that most pages in my webapp are okay but a couple of the Firefox is munging up. So, on my information page there is a gridview in the content section of the page. The masterpage contains...
0
7549
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7830
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7591
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7911
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6180
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5454
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1161
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.