Title: JavaScript Snippet doesn&#039;t work in text widget
Last modified: August 20, 2016

---

# JavaScript Snippet doesn't work in text widget

 *  Resolved [sirlucius](https://wordpress.org/support/users/sirlucius/)
 * (@sirlucius)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/javascript-snippet-doesnt-work-in-text-widget/)
 * The following code snippet does not work in my text wdiget on WordPress, is something
   wrong with my JavaScript? I’ve changed the URLs to xxx.com for this post:
 *     ```
       <SCRIPT LANGUAGE="javascript" TYPE="text/javascript>
   
       <!--
   
           // note: the 2nd image ("two") will be the first to appear in the animation
           // all images must be the same dimensions
           // works in NS 3, IE/NS 4+
           // other browsers or javascript disabled will see only the original image and link and no animation
   
           var has_loaded = 0;
   
           if (document.images) {
   
              one=new Image
              one.src="http://www.xxx.com/images/300x250ad1.jpg"
   
              two=new Image
              two.src="http://www.xxx.com/images/300x250ad2.jpg"
   
              three=new Image
              three.src="http://www.xxx.com/images/300x250ad3.jpg"
   
              four=new Image
              four.src="http://www.xxx.com/images/300x250ad4.jpg"
   
              five=new Image
              five.src="http://www.xxx.com/images/300x250ad5.jpg"
   
              has_loaded = 1;
           }
   
           go_URL = new Array();
              go_URL[0]="http://www.xxx.com";
              go_URL[1]="http://www.xxx.com";
              go_URL[2]="http://www.xxx.com";
              go_URL[3]="http://www.xxx.com";
              go_URL[4]="http://www.xxx.com";
   
           imgID = new Array();
              imgID[0]=one.src;
              imgID[1]=two.src;
              imgID[2]=three.src;
              imgID[3]=four.src;
              imgID[4]=five.src;
   
           var pause = 4000 // pause how long in milliseconds (1000 = 1 sec)
   
           var a = 0;
           var b = (go_URL.length - 1);
   
           function rotate(imgN) {
   
              if (has_loaded == 1) {
   
             if (a == b) {
            a = 0;
             }
             else {
            a++;
             }
   
             document.images[imgN].src = imgID[a];
             setTimeout('rotate("rotate_pic")',pause);
   
              } // end of if has_loaded
   
              if (window.status != '') { window.status = go_URL[a]; return true; }
           } // end of function rotate
   
           function goto_url() {
              if (document.images) {
             document.location=(go_URL[a]);
              }
              else {
             return false;
              }
           }
   
       //-->
           </SCRIPT>
       ```
   
 * I really appreciate any help and ideas on how to fix it. Thanks!

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

 *  [Christine Rondeau](https://wordpress.org/support/users/crondeau/)
 * (@crondeau)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/javascript-snippet-doesnt-work-in-text-widget/#post-2344692)
 * I don’t think that WordPress allows pasting of Javascript in posts, pages or 
   widgets. You might need to add this code to your sidebar.php instead.
 *  Thread Starter [sirlucius](https://wordpress.org/support/users/sirlucius/)
 * (@sirlucius)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/javascript-snippet-doesnt-work-in-text-widget/#post-2344758)
 * I found this plug-in : [http://wordpress.org/extend/plugins/html-javascript-adder/](http://wordpress.org/extend/plugins/html-javascript-adder/)
 * Which allows me to enter JavaScript, HTML, etc. into a widget box.
 *  [Christine Rondeau](https://wordpress.org/support/users/crondeau/)
 * (@crondeau)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/javascript-snippet-doesnt-work-in-text-widget/#post-2344849)
 * Cool, let us know if that works and if it does, can you mark the thread as resolved
   so that others may also benefit from the answer?
 * Cheers
 *  Thread Starter [sirlucius](https://wordpress.org/support/users/sirlucius/)
 * (@sirlucius)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/javascript-snippet-doesnt-work-in-text-widget/#post-2344854)
 * The plug-in for JavaScript / HTML etc. works, but my script doesn’t; however,
   that’s a separate issue.

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

The topic ‘JavaScript Snippet doesn't work in text widget’ is closed to new replies.

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [text widget](https://wordpress.org/support/topic-tag/text-widget/)
 * [wordpress widget](https://wordpress.org/support/topic-tag/wordpress-widget/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [sirlucius](https://wordpress.org/support/users/sirlucius/)
 * Last activity: [14 years, 7 months ago](https://wordpress.org/support/topic/javascript-snippet-doesnt-work-in-text-widget/#post-2344854)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
