Title: HTML editor corrupts Javascript
Last modified: August 19, 2016

---

# HTML editor corrupts Javascript

 *  Resolved [DrDaveHPP](https://wordpress.org/support/users/drdavehpp/)
 * (@drdavehpp)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/html-editor-corrupts-javascript/)
 * I’ve just run into a problem trying to incorporate a JS ad banner on one of our
   sites.
 * Basically, the WP rendering engine seems to be substituting UTF-8 HTML codes 
   for some of the characters – but only in certain places. Thus some ampersands(&),
   but not others, are rendered as & and some primes (‘), but not others, are rendered
   as ‘ , causing the JS to fail.
 * Here’s a cut and paste of a sample of the code as it should be:
 *     ```
       <script type="text/javascript">
       var uri = 'http://impgb.tradedoubler.com/imp?type(js)g(########)a(#######)' + new String (Math.random()).substring (2, 11);
       document.write('<sc'+'ript type="text/javascript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');
       </script>
       ```
   
 * And here’s how the last line but one is rendered in the page source:
 * `charset="ISO-8859-1"></sc'+'ript><strong>‘</strong>);`
 * Has anyone else run into this problem? And if so, has anyone worked out how to
   fix it?
 * Many thanks in advance. If I find a solution myself, I’ll come back and say so.
   🙂
 * Dave

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [DrDaveHPP](https://wordpress.org/support/users/drdavehpp/)
 * (@drdavehpp)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/html-editor-corrupts-javascript/#post-925655)
 * Sorry, the last line but one didn’t come out as I intended – I intended to emphasise
   the character between the two “strong” tags, which gets rendered as & 8 2 1 6;
 *  Thread Starter [DrDaveHPP](https://wordpress.org/support/users/drdavehpp/)
 * (@drdavehpp)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/html-editor-corrupts-javascript/#post-925699)
 * Sorted it with a tweak to the /wp-includes/formatting.php file.
 * Adjust the end of existing Line 61:
 *     ```
       ... } elseif (strpos($curl, '<code') !== false || strpos($curl, '<kbd') !== false || strpos($curl, '<style') !== false || strpos($curl, '<script') !== false) {
       ```
   
 * so that it ends:
 *     ```
       ... || strpos($curl, '<script') !== false || strpos($curl, 'ript>') !== false || strpos($curl, '//') !== false) {
       ```
   
 * Other similar tweaks would no doubt cure other similar problems with overzealous
   reformatting.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘HTML editor corrupts Javascript’ is closed to new replies.

## Tags

 * [characters](https://wordpress.org/support/topic-tag/characters/)
 * [encoding](https://wordpress.org/support/topic-tag/encoding/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [rendering](https://wordpress.org/support/topic-tag/rendering/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 1 participant
 * Last reply from: [DrDaveHPP](https://wordpress.org/support/users/drdavehpp/)
 * Last activity: [17 years, 5 months ago](https://wordpress.org/support/topic/html-editor-corrupts-javascript/#post-925699)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
