eXTReMe Tracker

Tuesday, October 31, 2006

Escaping HTML Character Entities in Javascript - ''' and '''

This blog has become a chronicle of wierdo bugs, so here's a new one to me. Maybe its not even a bug; but its annoying. I always thought that encoding HTML character entities in Javascript was a no-brainer until we ran across this bug tonight when launching a French version of a Yahoo! property. French language contains lots of apostrophe's (je t'aime, ce n'est pas, etc) and much to our dismay the HTML character entities for apostrophes, both ' and ' both seem to be automagically parsed as apostrophes and not special characters by Javascript, so instead of pulling out your hair trying to figure out why your code is broken, just escape the HTML entities like any other apostrophe would be. You can see for yourself with this little test right here. The first one is the escaped version... Second is not escaped and produces the error. You can do a view source if you don't believe me!


Thursday, October 19, 2006

Safari Debugging + DOM Tree Model

I never knew about this little trick but apparently its been around for a long time. Gives you javascript debugging and DOM tree. Supposedly Safari is getting a Firebug-like DOM inspection tool soon so this will be obsolete, but for now...

Type the following command in Terminal (while Safari is NOT running):

defaults write com.apple.Safari IncludeDebugMenu 1

Then launch Safari, and enjoy the new Debug menu. If you want to disable it again type the same comand only with a 0.

Wednesday, October 18, 2006

Yahoo Frontend Engineering Talks on Y!Video

Yahoo frontend engineering has uploaded some good talks for those of you out there who want to dig deeper into Javascript and the DOM. I recommend "An Inconvenient API: Theory of the DOM" by Douglas Crockford. Also featured are "The New Hackers Toolkit" and Joe Hewitt's talk at Y! about Firebug, the latest and greatest of Firefox extensions. They're not terribly exciting or visual so you can run em in the background while youre working, which is pretty nice. Thanks to Eric Miraglia for putting them online. Link