Archive for June, 2008

Mozilla’s “home” JavaScript function

Posted on June 30th, 2008 in JavaScript | 4 Comments »

I came across an interesting bug in someone’s code today. They had an iframe that was dynamically created and it’s url was different depending on whether the variable home was true or not. They had declared home a few lines earlier but the condition was always returning true no matter what. Turns out, there is already a variable of the same name in Mozilla-based browsers. It’s a function that when called, takes you to your home page set in your browser preferences.

I don’t have time to hack around with it at the moment, but I’d imagine that this is a slight security risk. Similar to Jeremiah Grossman’s CSS History Hack that can potentially tell all the sites you’ve visited recently, this one would tell what user’s home pages were set to. Initial thoughts are that this would be hard to do since the only way to call this function without leaving the page is to call it in an iframe (tried it and it works) but iframe sandboxing restrictions prevent code from the parent frame from seeing or accessing the contents of this iframe (or it’s window.location object) since it’s from a different domain. A quick check shows that this function doesn’t exist in Safari or Internet Explorer.

Google Gears + Google Reader = Heaven

Posted on June 27th, 2008 in make life easy | No Comments »

Oh man guys, I know that this is probably old news to the rest of you, but I just started using two of the coolest things together – and it rocks my face off!

Google Gears is a Firefox plugin that let’s you take web pages offline (essentially letting web developers save data to the visitors hard drive in a sqlite database). I thought about using it for this memory web app I’m building in my free time but decided it wasn’t worth all the extra effort at this point in time (you have to add in extra code to detect when users are offline and online, etc.)

Google Reader is Google’s aggregator capable of reading RSS and Atom feeds – essentially you use it to keep track of all the blogs you read in one place. I’ve been using iGoogle for the past two+ years and am slowly integrating all my feeds into Google Reader.

A few times a month I go on a two-hour train ride to see my girlfriend and family and have nothing to do while in commute (Why can’t you support tethering, iPhone?) Now I can combine the two things together and download all my blogs for viewing offline. Goodbye two boring hours!

Again, both these technologies are really old and everyone logically knows to use Gears with Reader but just in case you haven’t done so, here’s your reminder!

Next up, trying to access wikipedia offline.

Character encoding

Posted on June 27th, 2008 in Character Encoding, Internationalization | No Comments »

I always forget that when you change the character encoding of a webpage (say from ISO-8859-1 to UTF-8 or UTF-16) that you also have to change the character encoding of the actual file.

We were having an issue today while working on internationalization where we properly configured our server to spit out UTF16 pages but all the external JavaScript and CSS were rendering out Chinese characters. We racked our brains for awhile until we realized the external files were saved with a text-file encoding of ISO-8859-1. Manually converting a thousand plus files to a different character set would have taken ages luckily, one of our other web devs, Bryan, found out that you could automate this via unix command line (piconv). Rejoice!

As an added note, be aware that switching from a single byte character set like ISO-8859-1 to a double-byte like UTF-16 will double your file size. Thankfully gzipping your files makes this final file size increase much more palatable.

New Mac Firefox 3 + Firebug 1.2.0b3 = JavaScript errors?

Posted on June 24th, 2008 in Firefox, General Web Dev | No Comments »

So the new Firefox 3 that was released last week is awesome. It’s much faster, doesn’t seem to hog memory as much as the old one, and has a completely revamped bookmarks system which I enjoy. Mozilla reached it’s goal of getting in the Guinness World Records for the most downloaded application in a single day (8 million) and if you haven’t downloaded it yet I suggest you try it now. They also fixed a ton of bugs including the really annoying Mac flash overlay issue on transparent CSS backgrounds. Now if only FF3 was an auto-update…

Display and functionality-wise, all my pages seem to display exactly the same except for two issues:

  1. The first is a minor CSS issue with a horizontal bullet list. The whole lists is partially collapsed on each other with no spacing in between. Toggling the padding-left on this list via Firebug fixes the issue, so until the real issue is fix, I just do this toggling via JavaScript on document-ready for just this user agent.
  2. The second issue is the big one. On a good deal of my pages (in just FF3) I get JavaScript errors (variable is undefined) where some variable I set in the page through an inline script block cannot be found by another inline script (Google Adsense) and an external JS file on the same page. If I refresh the page a few times it seems to work so the issue is intermittin but huge, as JavaScript seems to not work at all when this issue occurs. If anyone wants to see an example of this or knows a solution let me know! I’ve been looking through Firefox’s Bug Tracker and haven’t found the issue, so I may log one myself if I can.

    Update: The issue seems to be caused when having the new Firebug 1.2.0b3 with Firefox (and possibly having the YSlow addon, too.) If you disable Firebug the errors go away and all functionality is restored. I hope this issue gets fixed soon! If you found this entry through a search engine and are also experiencing the issues please post here so we can see how big this issue is.

Generally though, FF3 is definitely worth the upgrade and besides the two issues above I experienced on my own project, I see no issue on the regular sites I visit.