Title: weird attempted escaping behaviour for javascript in post
Last modified: August 19, 2016

---

# weird attempted escaping behaviour for javascript in post

 *  [rutherford](https://wordpress.org/support/users/rutherford/)
 * (@rutherford)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/weird-attempted-escaping-behaviour-for-javascript-in-post/)
 * Hi. Usually I have no problem posting javascript in my posts (actual javascript
   code that will run when displayed on a client as opposed to just displaying source
   code). But now I am having some difficulty getting the following to work in a
   post:
 *     ```
       <script type="text/javascript">
       function displayContent(json) { 
   
       	var entries = json.feed.entry  || [];
       	var closingPrices = [];
       	var j = 0;
       	for(i=41;i<=51;i++){
       		closingPrices[j] = entries[i].content.$t.split(",")[0].split(":")[1].split(" ")[1];
       		j++;
       	}
   
       	var image = "http://chart.apis.google.com/chart?chs=250x100&amp;cht=lc&amp;chxt=x,y,r"+
       		"&amp;chxt=x,y,y&amp;chxl=0:|Nov%2028|Dec%205|12|1:|81|83|85|87|89|2:|in%2000s&amp;chds=81,89";
       	var chd = "&amp;chd=t:"
       	for(i=0;i<closingPrices.length;i++){
       		if(i>0) chd = chd + ",";
       		chd = chd + (""+(closingPrices[i]/100));
       	}
       	image = image + chd;
   
       	document.getElementById("chart").src = image;
   
       }
       </script>
       ```
   
 * For some reason, wordpress encodes some of the double quotes before uploading(“)
   but not others. Thus when I view the page the javascript fails with syntax errors
   on these wrongly encoded double quotes.
 * The quotes that are changed to “ in the above code are emboldened as follows:
   
   if(i>0) chd = chd + **“**,**“**; chd = chd + (**“**“+(closingPrices[i]/100));…
   document.getElementById(**“**chart**“**).src = image;
 * Why would WordPress encode some but not all and how can I prevent it from doing
   so?

The topic ‘weird attempted escaping behaviour for javascript in post’ is closed 
to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [rutherford](https://wordpress.org/support/users/rutherford/)
 * Last activity: [17 years, 4 months ago](https://wordpress.org/support/topic/weird-attempted-escaping-behaviour-for-javascript-in-post/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
