Use of 'Class' in Javascript
Here's a quick little tip that I discovered today about Javascript.
I'm currently writing a small in-context help addon for jQuery and wanted to add the option to specify a class name to give a help bubble. I did this using a setting and checked for it like such:
[javascript]if(settings.class != null)
{
bubble.addClass(settings.class);
}[/javascript]
This works great in Firefox, Opera, Chrome and even IE but throws an error in Safari.
It took me a while to figure out what was going on but I finally figured out that 'class' is a reserved word in Safari Javascript. Changing the code to:
[javascript]if(settings.classname != null)
{
bubble.addClass(settings.classname);
}[/javascript]
makes everything alright. So if you're getting a strange Parse error in Safari and nothing else, take a peek through your code and check you're not using the keyword class anywhere.