Title: Calling JavaScript in Post &#8211; Cant Get It Working
Last modified: August 21, 2016

---

# Calling JavaScript in Post – Cant Get It Working

 *  Resolved [globalsprawl](https://wordpress.org/support/users/globalsprawl/)
 * (@globalsprawl)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/calling-javascript-in-post-cant-get-it-working/)
 * Hi,
 * I am trying to use the following code in a page on my website. I have tested 
   it offline and it works well, but I cant seem to get it to work when i put it
   into the WordPress page.
 * The code in the page is:
 *     ```
       <script type="text/javascript" src="http://globalsprawl.com/scripts/changeit.js"></script>
   
       <div id="image1">
       <img src="http://globalsprawl.com/images/anthromes_1700.jpg" border="0" alt="one" />
       </div>
   
       <br><br>
   
       <a id="one" href="#" onclick="changeIt('http://globalsprawl.com/images/anthromes_1700.jpg','image1');">1700</a>
       <a id="two" href="#" onclick="changeIt('http://globalsprawl.com/images/anthromes_1800.jpg','image1');">1800</a>
       <a id="three" href="#" onclick="changeIt('http://globalsprawl.com/images/anthromes_1700.jpg','image1');">1900</a>
       <a id="four" href="#" onclick="changeIt('http://globalsprawl.com/images/anthromes_1700.jpg','image1');">2000</a>
       ```
   
 * And the changeit.js file is:
 *     ```
       <script type="text/javascript">
       function changeIt(imageName,objName)
       {
       	var obj = document.getElementById(objName);
   
       	var imgTag = "<img src='"+imageName+"' border='0' />";
   
       	obj.innerHTML = imgTag;
   
       	return;
       }
       </script>
       ```
   
 * I have looked at the following page, [http://codex.wordpress.org/Using_Javascript](http://codex.wordpress.org/Using_Javascript),
   as well as trawling the internet, but its just evading me.
 * The link to the page on the site is [http://globalsprawl.com/what-is-global-sprawl/](http://globalsprawl.com/what-is-global-sprawl/)
 * Thanks!

Viewing 1 replies (of 1 total)

 *  Thread Starter [globalsprawl](https://wordpress.org/support/users/globalsprawl/)
 * (@globalsprawl)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/calling-javascript-in-post-cant-get-it-working/#post-4641859)
 * Replying to myself, but the issue was that iPage was internally caching some 
   of the content, so an old error had been preserved. Contacted iPage who turned
   this caching off for me. The above (originally from [http://www.dynamicdrive.com/forums/showthread.php?16055-Change-Image-shown-on-mouse-click](http://www.dynamicdrive.com/forums/showthread.php?16055-Change-Image-shown-on-mouse-click))
   is now working fine.

Viewing 1 replies (of 1 total)

The topic ‘Calling JavaScript in Post – Cant Get It Working’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [globalsprawl](https://wordpress.org/support/users/globalsprawl/)
 * Last activity: [12 years, 3 months ago](https://wordpress.org/support/topic/calling-javascript-in-post-cant-get-it-working/#post-4641859)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
