While adding JavaScripts codes in Blogger template editor, we often face some weird XML Errors like Error parsing XML, line 768, column 20: The content of elements must consist of well-formed character data or markup. These sorts of errors occur when a JavaScript code is not well formed, or the codes are not written correctly by the developer.  Recently, one of our users asked us How to Correctly Add JavaScript Codes in Blogger?  This tutorial will turn out to be useful for those who are just starting to learn Blogger template and plugin development. In this article, we will show you How to Correctly Add JavaScript codes in Blogger?


The Blunder :

Before installing any new codes in his template a person should make sure that the script or style tags are properly closed. Most of the times you forget to copy the ending script tag, and in the end ultimately it shows errors.  For those who don’t know a lot they use codes like this:

<script>
jQuery(document).ready(function($) {
---------------------------
---------------------------
---------------------------
});

Here, it can clearly be seen that the <script> tag is not followed by a proper closing </script> tag which is wrong. The correct technique is to close the tags properly, like we do in simple HTML.  Let's go ahead and look at the right way of doing it.

How to Correctly Add JavaScript codes in Blogger?

Adding Scripts in Blogger is extremely straightforward. All you need to do is to go to Blogger.com >> Your site >> Template >> Edit HTML. Now it depends on you where you would like to paste your JavaScript coding. However, we prefer you to add it above the </head> tag because this is the place where all technical things are present. Here’s how the code would look like:

<script type='text/javascript'>
//<![CDATA[
Your JavaScript coding here
//]]>
</script>

Once the script is correctly added in your template hit the “Save Template” button, and this you would not face any errors. Which means that the JavaScript is correctly added in your blogger template.

We hope this tutorial has helped you in learning how to properly add javascript codes in blogger. Let us know about your experience? In case you have faced such errors too. Feel free to leave any error below that you are facing while adding new codes to your template. 

0 comments:

Post a Comment

 
Top