Thursday, 29 April 2010

An interesting DOCTYPE and JavaScript fix.

I've been working on a new project at work this week and found this interesting little bug. My JavaScript worked perfectly in a static page on my local server, but when it was moved into a dynamic template driven page, it failed, with a cryptic message in Firebug..

syntax error

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">

Not much use for debugging huh? Especially considering identical code worked perfectly on the static box. It turns out, that if you have a script without an "src"attribute set correctly, or if you have an error in an external JSON feed, the DOCTYPE will fail.

So then, this tricky to find, but easy to fix error is fixed by making sure every script your page is being called correctly. In my scenario, it was due to an error in and external JSON file.

Hope it helps.

Posted via web from Mark Kennard's Posterous

No comments:

Post a Comment