Sometime in the past few days, the Blogger team has made a change that breaks in-line JavaScript coded into a template. I first discovered this when I happened to check in on The Geek Tribune this morning and found that my layout was broken because the JavaScript-generated date text in my masthead was missing.
The reason the script stopped working is that newlines are being stripped from code such as...
<script language='JavaScript' type='text/javascript'> <!-- (javascript code) //--> </script>...so that it appears to the browser as...
<script language='JavaScript' type='text/javascript'> <!-- (javascript code)//--> </script>This, of course, effectively comments out the script.
One could simply delete the <!-- --> pair, but then – if you're using an XHTML 1.0 doctype, as I am – Blogger's template editor complains about the XML not being well formed.
I admit I've never liked using CDATA, mostly because I find the syntax difficult to remember, but it seemed like it might be just the thing to keep Blogger from messing with my XHTML template. I replaced the HTML-style comments with...
<script language='JavaScript' type='text/javascript'> //<![CDATA[ (javascript code) //]]> </script>...and voila! My scripts are back in business.
No comments:
Post a Comment