Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,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 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[4,661 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 whomever posted them. This site is not responsible for what they say.
A hint?
Authored by: npike on Thu, Jul 10 2008 at 8:25AM PDT
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 Thu, Jul 10 2008 at 9:29AM PDT
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 Thu, Jul 10 2008 at 10:31AM PDT
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 Thu, Jul 10 2008 at 12:40PM PDT

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: richiesmit on Thu, Jul 10 2008 at 2:47PM PDT
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 Thu, Jul 10 2008 at 7:44PM PDT
Delete, delete, delete!

[ Reply to This | # ]
A Firefox 3 JavaScript gotcha for web site builders
Authored by: drow on Fri, Jul 11 2008 at 12:25AM PDT
exterminate! exterminate!

[ Reply to This | # ]
A Firefox 3 JavaScript gotcha for web site builders
Authored by: S on Fri, Jul 11 2008 at 5:03AM PDT
Exterminieren! Exterminieren!
Did we miss any?

[ Reply to This | # ]