Document.write(<script>) throws Unexpected token "ILLEGAL"

Viewed 9388

Before you ask, I already searched a lot in Stack Overflow and I google it thousand times. Any other case I ever seen here helped me.

Let's go to my problem:

I'm trying to use the following script in my code:

<script type='text/javaScript'>
    document.write("<script src='/feeds/posts/default/-/"+hom_cat1+"?max-results=1&orderby=published&alt=json-in-script&callback=showhomeposts1'></script>");
</script>

But I'm using Blogger and it don't detect correctly my code (note the red script closing tag):

note the red script closing tag

With this, I can't save the Template. So I'm trying to use convert my code into HTML entities using this website. When I encode, put this into my template and save, I get:

Uncaught SyntaxError: Unexpected token ILLEGAL 

Here's the encoded string I'm trying to use:

&lt;script type='text/javaScript'&gt;document.write(&quot;&lt;script src='/feeds/posts/default/-/&quot;+hom_cat1+&quot;?max-results=1&amp;orderby=published&amp;alt=json-in-script&amp;callback=showhomeposts1'&gt;&lt;/script&gt;&quot;);&lt;/script&gt;

What can I do to solve my issue?

4 Answers
Related