In some of my code samples in this blog you will see javascript blocks like this:
<script type='text/javascript'>
... code ...
</script>
And in some like this:
<script type='text/javascript'>
//<![CDATA[
... code ...
//]]>
</script>
You might ask: What is that CDATA? Why cannot he make up his mind which one to use? Can I stick to one of the notations?
Blogger layout template must be valid XML, otherwise it won't pass validation and you cannot save it. In XML for example character < starts a tag. Lets assume you want to run the following javascript code, which you have found somewhere in internet:
<script type='text/javascript'>
alert("Tip of the day: 5 < 6 & 1 < 2");
</script>
But if you put that on your template and try to save or preview, you'll get:
Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
XML error message: The content of elements must consist of well-formed character data or markup.
Now there are two ways to correct this script before pulling out your hair. To make the original script to be valid XML inside script tags, you must escape certain characters, like <, >, and &. And if you don't escape, the template editor will escape " and ', too. The script in your template becomes:
<script type='text/javascript'>
alert("Tip of the day: 5 < 6 & 1 < 2");
</script>
You can use HTML Escape Tool (from htmlescape.net) and similar tools to escape the javascript code, if you don't want to do it by hand. There are also tools for unescaping the characters.
Ok, as you see that "messes up" the code and makes it harder to maintain. Another solution is to mark the code between <script> and </script> tags as CDATA (character data). This tells XML parser that the text is general character data, instead of XML to be parsed. You may have already guessed, it looks like this:
<script type='text/javascript'>
//<![CDATA[
alert("Tip of the day: 5 < 6 & 1 < 2");
//]]>
</script>
The latter is perfect, you may think. It is good, but, there is a but. If you want to use widget tags for templates, you cannot mark those sections as CDATA. I'll give you a simple example.
<script type='text/javascript'>
alert("<data:blog.url/>");
</script>
In this script you must not escape <data:blog.url/>, because it is template data tag http://www.google.com/support/blogger/bin/answer.py?hl=en&answer=47270. You can escape "s to "s, and if you don't, Blogger will do it for you. But if you try this:
<script type='text/javascript'>
//<![CDATA[
alert("<data:blog.url/>");
//]]>
</script>
It does not show your blog address, but the text "<data:blog.url/>", which probably was not the intention.
For some reason, you cannot find this information in Blogger help.
Some references:
Wikipedia CDATA
Javascript and XHTML
Click on a single comment to hide/show its text
60 comments:
Excelent, is just that I have searching for.
But, I have a code like this:
/* */
What's the function of /* an */?
Thanks
17I just saw that the element "CDATA" onmy comment is disappeared, and was inconprensible!
Thanks for sharing this info, I've also come across Sitepoint's javascript tutorial which was pretty helpful when I needed to problem solve issues.
@Jorge deSaliceta
It's a comment tag Jorge. The text inside that are just an explanation of what the code does.
It's sort of a programmer's note.
Thanks for the explanation. It's useful to know why you need to use that! :)
Thank you for sharing this wonderful information.
Javascript Course | Javascript Training Institute in Chennai
Appreciate Your Work... Thanks for Sharing Useful Information. I Just want to Share Some information related to HTML5 training in Chennai hope it is useful for the Community Here.
Quite Interesting post!!! Thanks for posting such a useful blog. Keep posting it’s really helpful to enhance my skill set, keep blogging.
Regards,
Java J2EE Training in Chennai|Java Training Institute in Chennai
Quite Interesting post!!! Thanks for posting such a useful blog. Keep posting it’s really helpful to enhance my skill set, keep blogging.
HTML5 Training in Chennai
HTML5 Training in Chennai
It is indeed an informational one ! Thank you for sharing your knowledge. Hope this is of use,
html5training
i went through your blog and now i got a basic idea about HTML5 .It was very useful for me. when i was searching for HTML5 tutorials i came across html5training.in . Is this a good site to learn HTML5
Thanks for sharing a useful blog. keep posting
HTML5 TRAINING IN CHENNAI
Thanks for the info...
Real Trainings provide all IT-Training Institutes information in Hyderabad, Bangalore, Chennai . Here students can Compare all Courses with all detailed information. In Real trainings we provide courses like GPS Infotec, Eduwizz online training, Akshara Technologies, Spark Trainings, Visualpath etc...
Thanks for sharing this informative post. I'll use this as a reference. Keep blogging. Regards.
JavaScript Training in Chennai | JavaScript Course in Chennai | JavaScript Training institute in Chennai | JavaScript Course | JavaScript Training | JavaScript Training Center in Chennai | JavaScript Training Courses | JavaScript Training Classes
i preview the details about the javascript..happy to see this and very helpful for me and thanks for the details
Javascript Training in Bangalore
Java script Training in Bangalore
Javascript Training Institutes in Bangalore
Javascript Course in Bangalore
Javascript Training Courses in Bangalore
Really very happy to say, your post is very interesting to read. I never stop myself to say something about it. You’re doing a great job. Keep it up.php training in Mumbai
Thanks for the update admin, early waiting for the next session of your blog.
Cloud Computing Courses in Chennai
Hadoop Training in Chennai
Digital Marketing Course in Chennai
Selenium Training in Chennai
JAVA Training in Chennai
German Classes in chennai
Big Data Training in Chennai
Big Data Course in Chennai
thank you for your info on html5 training in chennai
Good Stuff. Thank you for providing such a valuable information. I am looking forward to visit your blog at daily basis.
If you’re looking for a safety training institute in Chennai, it doesn’t get better than POSHE Solutions.
NEBOSH Course in Chennai
Fire and safety course in vizag
Fire and safety course in vizag
Hi MS-potilas ,
Thanks for Clear and brief Content MS-potilas. Your Knowledge towards Html and Javascript Would help all the Programmers, intermediate programmer, students and Working Professional.Please share your knowledge and all sort of ideas in your blog. It will be helpful for everybody.Keep Blogging!!!!! All the Best!!!!
Regards
Nihal Blog Follower
HTML5 TRAINING IN CHENNAI
Thanks for sharing your views about the concept which you know much better. Its easy to read and understand by the way you wrote the blog contents.
Data science training in porur
Data science training in Tambaram
Data science training in OMR
Data science training in chennai
Data science course in chennai
Cloud computing training in T Nagar
Cloud computing training in OMR
Cloud computing training in velachery
The blog is so interactive and Informative , you should write more blogs like this. We provide Datascience training with real time experts and 100% placement program Datascience Training
Thanks for sharing this great blog. That is very interesting to read and I am always searching for informative blog like this.
Html5 Training in Chennai
Html5 Courses in Chennai
Html5 Training in OMR
DOT NET Training in Chennai
.net coaching centre in chennai
QTP Training in Chennai
LoadRunner Training in Chennai
Html5 Training in Chennai
very nice blog. Thanks for sharing the post.
safety course in chennai
fire and safety course in chennai
industrial safety course in chennai
nebosh course in chennai
safety courses in india
safety officer course in chennai
diploma in fire and safety course chennai
nebosh igc course in chennai
Thanks for sharing a piece of valuable information to us. keep on sharing like this.
Best Aviation Academy in Chennai
Best Air hostess Training in Chennai
Pilot Training in Chennai
Airport Ground handling Training in Chennai
Airport Flight Dispatcher Trainee in Chennai
RTR - Aero Training in Chennai
Cabin Crew Training in Chennai
Aviation Academy in Chennai
Aviation training institute in Chennai
I really like your post. Thanks for sharing such a valuable post. Please keep sharing such kind of post. It will be helpful for other.
Delhi's best python institute
Noida's best python institute
Gurgaon's best python institute
I went through your blog, it was very helpful to me and I got some fresh data as well...
data science courses near bangalore|
data science classes in marathahalli|
hadoop courses near bellandur|
hadoop classes in kalyan nagar
such a great blog.Thanks for sharing this useful information.
Web Designing Course in chennai
web designing training in chennai
IELTS coaching in Chennai
angularjs training in chennai
Spoken English Classes in Chennai
Software Testing Training in Chennai
PHP Training in chennai
Web designing Training in OMR
Web designing Training in Porur
Web designing Training in Adyar
It is very good and very informative. There is a useful information in it.Thanks for posting... Machine Learning Training In Hyderabad
Great blog, I was searching this for a while. Do post more like this.
Angular 4 Training in Chennai
Angular 5 Training in Chennai
Angular Training in Chennai
ReactJS Training in Chennai
PHP course in Chennai
Web Designing Training in Chennai
AngularJS Training in Anna Nagar
AngularJS Training in Vadapalani
AngularJS Training in Thiruvanmiyur
Very nice blog.
safety course in chennai
industrial safety course in chennai
fire and safety course in chennai
nebosh course in chennai
I recently came across your blog and have been reading along. I thought I would leave my first comment.
Hadoop Online Training
Superb ! Your blog is incredible. I am delighted with it. Thanks for sharing with me.
Hadoop training in Chennai
Python training in Chennai
Spark training in Chennai
Data Science with Python training in Chennai
Good post!Thank you so much for sharing this lovely article.It was so good to read and useful to upgrade my understanding...
salesforce Training in Bangalore
uipath Training in Bangalore
blueprism Training in Bangalore
Hiii..Thanks for Sharing Great info...Nice post...Keep move on...
Angular JS Training in Hyderabad
awesome article,the content has very informative ideas, waiting for the next update...
SAS Training in Chennai
SAS Training Center in Chennai
SAS Analytics Training in Chennai
SAS Training in Anna Nagar
SAS Training in Tnagar
clinical sas training in chennai
Mobile Testing Training in Chennai
QTP Training in Chennai
Hibernate Training in Chennai
DOT NET Training in Chennai
This is a very Amazing and Very Informative Article we get a lot of pieces of information from this article we really appreciate your teamwork keep it up and keep posting such informative articles...
Washing Machine
Such a great post. Thanks for sharing.
Bigdata training in Pallikranai
Machine learning training in Pallikranai
Spark training in Pallikranai
Data analytics training in Pallikranai
Data science training in Pallikranai
Spark with ML training in Pallikranai
Python training in Pallikranai
MongoDB training in Pallikaranai
Hadoop training in Pallikranai
Garmin Care Map Update team is here to help you Garmin map updates/download! Troubleshooting all issues concerning maps update, just call at 0330-113-3590 and get help to fix your issue.
Garmin Map Updates
Garmin Support
Garmin Com/Express
Nice blog..! I really loved reading through this article. Thanks for sharing such a amazing post with us and keep blogging...Well written article
aws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
Nice...
t system placement paper
advantages of package in java
2xwy cable full form
react native developer resume sample
log(a2/bc) + log(b2/ac(c2/ab) is
error: cannot find module '../lib/utils/unsupported.js'
django.core.exceptions.improperlyconfigured: error loading mysqldb module.
infix to postfix python
what is your biggest achievement yahoo answers
toughest pattern programs in c
Thank you for sharing the article. The data that you provided in the blog is informative and effective.
Best javascript Online Training Institute
Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
top angularjs online training
best angularjs online training
angularjs online training
This post gives a piece of excellent information. Keep sharing this blog.
Spoken English Classes in Bangalore
Spoken English Classes in Chennai
English Speaking Course in Bangalore
Best Spoken English Classes in Bangalore
Spoken English in Bangalore
English Speaking Classes in Bangalore
AWS Training in Bangalore
Data Science Courses in Bangalore
DOT NET Training in Bangalore
DevOps Training in Bangalore
Thanks for the post. It was very interesting and meaningful. I really appreciate it! Keep updating stuff like this.
We are giving all Programming Courses such as You can
Register for a free Demo Sessions
RPA Ui Path Online Training
Best Python Online Training
Online AWS Training
Online Data Science Training
Hadoop Online Training
Really wonderful blog completely enjoyed reading and learning to gain the vast knowledge. Eventually, this blog helps in developing certain skills which in turn helpful in implementing those skills. Thanking the blogger for delivering such a beautiful content and keep posting the contents in upcoming days.
data science institute in bangalore
Excellent blog, Thanks for sharing this information.
Full stack classes in ahmedabad
Excellent work done by you once again here. This is just the reason why I’ve always liked your work. You have amazing writing skills and you display them in every article. Keep it going!
data scientist training and placement
A good blog always comes-up with new and exciting information and while reading I have feel that this blog is really have all those quality that qualify a blog to be a one
data scientist training and placement
I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.
DevOps Training in Hyderabad
DevOps Course in Hyderabad
Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work.
AWS Training in Hyderabad
AWS Course in Hyderabad
Exceptionally instructive case! There is loads of hint here that could previously any situation income started further to a rich interpersonal interaction cognizant up assessment. thanks! Clash Of Clans Hack Game Download
Best announce! this is an each level of simple to apply weblog that I can conclusively come steerage to more prominent age this yr! gratitude for useful declare. thanks! Wifi Hacker Pc
We have a professional and expert team of CA who gave you productive results. Our CA will deal with all your Annual Compliance for Companies and help to complete all the documentation work.
Trademark Registration in Mumbai
Trademark Registration in Delhi
GST Registration in Jaipur
CA in Delhi
CA in Pune
CA in Mumbai
CA in Jaipur
Company Registration in Ahmedabad
Trademark Registration in Ahmedabad
Trademark Registration in Agra
your post is really amazing with lots of important points Thank you for sharing. I was really enjoying reading this article. We provide 20% theoretical classes rather than practical training to clear all concepts of basic fundamentals of mobile repairing in our advanced mobile repairing course in Delhi.
See the hack to make the 'Post a Comment' link bigger.
Post a Comment