Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A Firefox 3 JavaScript gotcha for web site builders Web Browsers
Here's a little gotcha in Firefox 3.0 for web site designers. My website was incorrectly formatted in Firefox 3, but worked fine in Firefox 2. I had some JavaScript code that did the following:
  mainTabDiv.style.left = (mainTabBarLeft-mainTabBarDX)+'px;';
  mainTabDiv.style.top = mainTabBarTop+'px';
With that code in Firefox 3, mainTabDiv was not positioned correctly -- it was at 0. So I put in an alert:
alert(" left="+mainTabDiv.style.left+" mtbl="+mainTabBarLeft+" mainTabBarDX="+mainTabBarDX);
and got the following output:
left= mtbl=270 mainTabBarDX=2
Can you spot the problem? The first statement in my source has px; and the second one has px. That is, the failing statement had a semicolon at the end of the string. In Firefox 2 this worked OK. In Firefox 3, the assignment does nothing. So check your JavaScript for stray semicolons if you're having site issues in Firefox 3.
    •    
  • Currently 1.40 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[6,964 views]  

A Firefox 3 JavaScript gotcha for web site builders | 8 comments | Create New Account
Click here to return to the 'A Firefox 3 JavaScript gotcha for web site builders' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A hint?
Authored by: npike on Jul 10, '08 08:25:57AM

This is not really a hint or a tip at all. What you used in Firefox 2 (while it worked), is technically not valid to begin with.

I doubt many developers are making the same mistake, at least I hope not.



[ Reply to This | # ]
A Firefox 3 JavaScript gotcha for web site builders
Authored by: enigmamf on Jul 10, '08 09:29:37AM

And it's definitely not a Mac OS X Hint :)



[ Reply to This | # ]
A Firefox 3 JavaScript gotcha for web site builders
Authored by: osxpounder on Jul 10, '08 10:31:11AM

I'm grateful to see this hint anyway. Thanks for taking the time to share it.



[ Reply to This | # ]
A Firefox 3 JavaScript gotcha for web site builders
Authored by: Snowgen on Jul 10, '08 12:40:49PM

This boils down to:

Problem: Sucky code doesn't run.
Hint: Fix the sucky code.

Wow. Real friggin' eureka moment there.



[ Reply to This | # ]
Check for stray semicolons
Authored by: Anonymous on Jul 10, '08 02:47:21PM

Yay. Check for stray noddy programmer tips.

Really, this has no place here.



[ Reply to This | # ]
A Firefox 3 JavaScript gotcha for web site builders
Authored by: spockboy on Jul 10, '08 07:44:39PM

Delete, delete, delete!



[ Reply to This | # ]
A Firefox 3 JavaScript gotcha for web site builders
Authored by: drow on Jul 11, '08 12:25:51AM

exterminate! exterminate!



[ Reply to This | # ]
A Firefox 3 JavaScript gotcha for web site builders
Authored by: S on Jul 11, '08 05:03:14AM
Exterminieren! Exterminieren!
Did we miss any?

[ Reply to This | # ]