Monday, August 13, 2007

single quotation will be converted to double quotation in adding HTML/JavaScript via Page Element page

At Blogger's "Add and Arrange Page Elements" page, you can add "HTML/JavaScript" element to your blog. However, when you save your HTML or JavaScript via that function, single quotation will be converted to double quotation automatically, unless the single quotation character(s) are in comment line(s).
For an example, about these lines:
<div class='menuBar'>
<a class='menuButton' href='http://cluelessbloggerhours.blogspot.com' onmouseover='linkButtonMouseover( event);'>Home</a>
<span class='menuButton' href='' onclick='return buttonClick(event,"tocMenu");' onmouseover='buttonMouseover(event,"tocMenu");'>Table of Conents</span>
<span class='menuButton' href='' onclick='return buttonClick(event,"labelMenu");' onmouseover='buttonMouseover(event,"labelMenu");'>Label</span>
</div>

After saving, those become like below. Check span tag statements.

<div class="menuBar">
<a onmouseover="linkButtonMouseover( event);" class="menuButton" href="http://cluelessbloggerhours.blogspot.com">Home</a>
<span ); tocmenu onmouseover="buttonMouseover(event," class="menuButton" href="" onclick="return buttonClick(event,">Table of Conents</span>
<span ); onmouseover="buttonMouseover(event," class="menuButton" href="" labelmenu onclick="return buttonClick(event,">Label</span>
</div>
This is not desirable behavior, since we supporse to be able to add/edit HTML line there. What makes this more confusing is that double quotation surrounding tag's attribute value for editing template directly at "Edit HTML" menu under Template tab will be automatically converted to single quotation, and, at there, single quotation used in attribute value will be converted to double quotation. Well, when you work your blog at the add-"HTML/JavaScript"-element window, keep the following way:
  • Use double quotation, instead of single quotation, to enclose clause of attribute value.
  • If it's JavaScript, then always put your JavaScript codes between HTML comment tags:
    <script type="text/javascript">
    <!--
    Your JavaScript codes here
    //-->
    </script>
And when you work your blog by editing template directly at "Edit HTML" menu under Template tab, then keep using single quotation to enclose attribute value.

No comments: