Title: Javascript Scroll bar in post
Last modified: August 19, 2016

---

# Javascript Scroll bar in post

 *  [someguy03](https://wordpress.org/support/users/someguy03/)
 * (@someguy03)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/javascript-scroll-bar-in-post/)
 * I am trying to integrate this into a wordpress post:
 * [http://www.n-son.com/scripts/jsScrolling/example4.html](http://www.n-son.com/scripts/jsScrolling/example4.html)
 * It’s a very minimalistic corporate site with fixed dimensions so they want a 
   scroll bar on the text.
 * I put the javascript call in the header as instructed:
 * <script type=”text/javascript” src=”src/jsScroller.js”></script>
    <script type
   =”text/javascript” src=”src/jsScrollbar.js”></script>
 * I also tried putting the script and the CSS in the post, and the text/css loads,
   but the javascript does not. Any help?

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

 *  [Mark Ratledge](https://wordpress.org/support/users/songdogtech/)
 * (@songdogtech)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/javascript-scroll-bar-in-post/#post-1702829)
 * In header.php, try the full path to your copies of those two scripts.
 *  Thread Starter [someguy03](https://wordpress.org/support/users/someguy03/)
 * (@someguy03)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/javascript-scroll-bar-in-post/#post-1702830)
 * Thanks for the help, here’s a portion of my header, is this correct?
 *     ```
       <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   
       <html xmlns="http://www.w3.org/1999/xhtml">
   
       <head>
   
       <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   
       <script type="text/javascript" src="http://kylefoleydesign.com/rbfgroup/css/jsScrollbar.js"></script>
       <script type="text/javascript" src="http://kylefoleydesign.com/rbfgroup/css/jsscroller.js"></script>
   
       <title><?php bloginfo('name'); ?>: <?php bloginfo('description'); ?> <?php wp_title(); ?></title>
       ```
   
 *  [Mark Ratledge](https://wordpress.org/support/users/songdogtech/)
 * (@songdogtech)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/javascript-scroll-bar-in-post/#post-1702831)
 * Does it work? Does [Firebug](http://getfirebug.com/) show the JS loading OK?
 *  Thread Starter [someguy03](https://wordpress.org/support/users/someguy03/)
 * (@someguy03)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/javascript-scroll-bar-in-post/#post-1702835)
 * No, it is not working. The Firebug console just says:
 * > syntax error
   >  [Break on this error] var scrollbar = null;</p>\n
 * Here’s the code I have for the post. For testing purposes I extracted it right
   from that example I posted earlier:
 *     ```
       <style type="text/css">
       .Scroller-Container {
   
       }
       .Scrollbar-Up {
         position: absolute;
         width: 10px; height: 10px;
         background-color: #CCC;
         font-size: 0px;
       }
       .Scrollbar-Track {
         width: 10px; height: 160px;
         position: absolute;
         top: 20px;
         background-color: #EEE;
       }
       .Scrollbar-Handle {
         position: absolute;
         width: 10px; height: 30px;
         background-color: #CCC;
       }
       .Scrollbar-Down {
         position: absolute;
         top: 190px;
         width: 10px; height: 10px;
         background-color: #CCC;
         font-size: 0px;
       }
       #Scrollbar-Container {
         position: absolute;
         top: 50px; left: 460px;
       }
   
       #Container {
         position: absolute;
         top: 50px; left: 50px;
         width: 400px;
         height: 200px;
         background-color: #EEE;
       }
       #News, #About, #Extra {
         position: absolute;
         top: 10px;
         overflow: hidden;
         width: 400px;
         height: 180px;
         display: none;
       }
       #News {display: block;}
       p {
         margin: 0; padding: 0px 20px 10px;
         font-family: Verdana, Arial, Helvetica, sans-serif;
         font-size: 11px;
         text-indent: 20px;
         color: #777;
       }
       #Navigation {
         position: absolute;
         top: 30px;
         left: 75px;
       }
       #Navigation a {
         margin: 5px 2px 0 0;
         padding: 0 5px;
         height: 20px;
         background-color: #E4E4E4;
         font-family: Verdana, Arial, Helvetica, sans-serif;
         font-size: 10px;
         color: #AAA;
         text-decoration: none;
         display: block;
         float: left;
         letter-spacing: 1px;
       }
       #Navigation a:hover {
         margin-top: 0px;
         height: 25px;
       }
       #Navigation a.current {
         margin-top: 0px;
         height: 25px;
         background-color: #EEE;
         color: #777;
       }
       </style>
       <script type="text/javascript">
       var scroller  = null;
       var scrollbar = null;
   
       window.onload = function () {
         scroller  = new jsScroller(document.getElementById("News"), 400, 180);
         scrollbar = new jsScrollbar (document.getElementById("Scrollbar-Container"), scroller, true, scrollbarEvent);
       }
   
       function scrollbarEvent (o, type) {
       	if (type == "mousedown") {
       		if (o.className == "Scrollbar-Track") o.style.backgroundColor = "#E3E3E3";
       		else o.style.backgroundColor = "#BBB";
       	} else {
       		if (o.className == "Scrollbar-Track") o.style.backgroundColor = "#EEE";
       		else o.style.backgroundColor = "#CCC";
       	}
       }
   
       function swapIt(o) {
       	o.blur();
       	if (o.className == "current") return false;
   
       	var list = document.getElementById("Navigation").getElementsByTagName("a");
       	for (var i = 0; i < list.length; i++) {
       		if (list[i].className == "current") {
       			list[i].className = "";
       			document.getElementById(list[i].title).y = -scroller._y;
       		}
       		if (list[i].title == o.title) o.className = "current";
       	}
   
       	list = document.getElementById("Container").childNodes;
       	for (var i = 0; i < list.length; i++) {
       		if (list[i].tagName == "DIV") list[i].style.display = "none";
       	}
   
       	var top = document.getElementById(o.title);
       	top.style.display = "block";
       	scrollbar.swapContent(top);
       	if (top.y) scrollbar.scrollTo(0, top.y);
   
       	return false;
       }
       </script>
   
       <div id="Navigation">
   
         <a href="#" onclick="return swapIt(this)" title="News" class="current">news</a>
         <a href="#" onclick="return swapIt(this)" title="About">about</a>
         <a href="#" onclick="return swapIt(this)" title="Extra">extra</a>
       </div>
       <div id="Container">
         <div id="News">
           <div class="Scroller-Container">
             <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec iaculis, ante et congue feugiat, elit wisi commodo metus, ut commodo ligula enim ac justo. Pellentesque id ligula. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Phasellus vitae mi a elit dictum volutpat. Pellentesque nec arcu. Etiam blandit. Phasellus egestas dolor ut lacus. Sed enim justo, sagittis ut, condimentum non, ullamcorper eu, neque. In hac habitasse platea dictumst. Integer ipsum risus, sagittis ac, imperdiet ac, interdum sed, libero. Praesent commodo. Mauris congue, urna eget hendrerit elementum, dolor ligula ultrices neque, in elementum ante erat et elit.</p>
   
             <p>Vivamus vehicula. Integer cursus massa et nisl. Morbi pretium sem eget risus. Vestibulum nec est. Donec feugiat purus et ligula. Quisque semper. Sed eu ante. Curabitur suscipit porttitor libero. Nam eros leo, sollicitudin eget, tincidunt vitae, facilisis a, dui. Proin neque. Aliquam erat volutpat. Pellentesque felis.</p>
             <p>Aliquam consequat. Proin feugiat ultricies dui. Suspendisse mollis dui nec nunc. Nam tristique, ante vitae imperdiet vestibulum, elit nulla rhoncus nisl, vitae tincidunt dolor dui eu mi. In hac habitasse platea dictumst. Nunc blandit dolor vel mauris. Proin wisi. Nam pharetra ultrices tellus. Sed arcu. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam ultricies semper wisi. Sed nisl. Donec blandit. Nunc vitae urna sed nisl mattis ornare.</p>
             <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec iaculis, ante et congue feugiat, elit wisi commodo metus, ut commodo ligula enim ac justo. Pellentesque id ligula. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Phasellus vitae mi a elit dictum volutpat. Pellentesque nec arcu. Etiam blandit. Phasellus egestas dolor ut lacus. Sed enim justo, sagittis ut, condimentum non, ullamcorper eu, neque. In hac habitasse platea dictumst. Integer ipsum risus, sagittis ac, imperdiet ac, interdum sed, libero. Praesent commodo. Mauris congue, urna eget hendrerit elementum, dolor ligula ultrices neque, in elementum ante erat et elit.</p>
             <p>Vivamus vehicula. Integer cursus massa et nisl. Morbi pretium sem eget risus. Vestibulum nec est. Donec feugiat purus et ligula. Quisque semper. Sed eu ante. Curabitur suscipit porttitor libero. Nam eros leo, sollicitudin eget, tincidunt vitae, facilisis a, dui. Proin neque. Aliquam erat volutpat. Pellentesque felis.</p>
             <p>Aliquam consequat. Proin feugiat ultricies dui. Suspendisse mollis dui nec nunc. Nam tristique, ante vitae imperdiet vestibulum, elit nulla rhoncus nisl, vitae tincidunt dolor dui eu mi. In hac habitasse platea dictumst. Nunc blandit dolor vel mauris. Proin wisi. Nam pharetra ultrices tellus. Sed arcu. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam ultricies semper wisi. Sed nisl. Donec blandit. Nunc vitae urna sed nisl mattis ornare.</p>
           </div>
   
         </div>
         <div id="About">
           <div class="Scroller-Container">
             <p>Aliquam consequat. Proin feugiat ultricies dui. Suspendisse mollis dui nec nunc. Nam tristique, ante vitae imperdiet vestibulum, elit nulla rhoncus nisl, vitae tincidunt dolor dui eu mi. In hac habitasse platea dictumst. Nunc blandit dolor vel mauris. Proin wisi. Nam pharetra ultrices tellus. Sed arcu. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam ultricies semper wisi. Sed nisl. Donec blandit. Nunc vitae urna sed nisl mattis ornare.</p>
             <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec iaculis, ante et congue feugiat, elit wisi commodo metus, ut commodo ligula enim ac justo. Pellentesque id ligula. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Phasellus vitae mi a elit dictum volutpat. Pellentesque nec arcu. Etiam blandit. Phasellus egestas dolor ut lacus. Sed enim justo, sagittis ut, condimentum non, ullamcorper eu, neque. In hac habitasse platea dictumst. Integer ipsum risus, sagittis ac, imperdiet ac, interdum sed, libero. Praesent commodo. Mauris congue, urna eget hendrerit elementum, dolor ligula ultrices neque, in elementum ante erat et elit.</p>
             <p>Vivamus vehicula. Integer cursus massa et nisl. Morbi pretium sem eget risus. Vestibulum nec est. Donec feugiat purus et ligula. Quisque semper. Sed eu ante. Curabitur suscipit porttitor libero. Nam eros leo, sollicitudin eget, tincidunt vitae, facilisis a, dui. Proin neque. Aliquam erat volutpat. Pellentesque felis.</p>
           </div>
   
         </div>
         <div id="Extra">
           <div class="Scroller-Container">
             <p>Vivamus vehicula. Integer cursus massa et nisl. Morbi pretium sem eget risus. Vestibulum nec est. Donec feugiat purus et ligula. Quisque semper. Sed eu ante. Curabitur suscipit porttitor libero. Nam eros leo, sollicitudin eget, tincidunt vitae, facilisis a, dui. Proin neque. Aliquam erat volutpat. Pellentesque felis.</p>
           </div>
         </div>
       </div>
       <div id="Scrollbar-Container">
         <div class="Scrollbar-Up"></div>
   
         <div class="Scrollbar-Down"></div>
         <div class="Scrollbar-Track">
           <div class="Scrollbar-Handle"></div>
         </div>
       </div>
       ```
   
 *  Thread Starter [someguy03](https://wordpress.org/support/users/someguy03/)
 * (@someguy03)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/javascript-scroll-bar-in-post/#post-1702840)
 * Here’s the test page:
 * [http://kylefoleydesign.com/rbfgroup/?page_id=62#](http://kylefoleydesign.com/rbfgroup/?page_id=62#)
 *  [jlevan](https://wordpress.org/support/users/jlevan/)
 * (@jlevan)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/javascript-scroll-bar-in-post/#post-1702870)
 * Where did you upload jsScroller.js and jsScrollbar.js?
 * They are not at the location specified in your page. I also tried some more common
   locations in the theme’s directory, but did not see the files.
 *  Thread Starter [someguy03](https://wordpress.org/support/users/someguy03/)
 * (@someguy03)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/javascript-scroll-bar-in-post/#post-1702871)
 * Sorry, I was doing some experiments while you were looking at it:
 * [http://kylefoleydesign.com/rbfgroup/css/jsScroller.js](http://kylefoleydesign.com/rbfgroup/css/jsScroller.js)
   
   [http://kylefoleydesign.com/rbfgroup/css/jsScrollbar.js](http://kylefoleydesign.com/rbfgroup/css/jsScrollbar.js)
 *  [jlevan](https://wordpress.org/support/users/jlevan/)
 * (@jlevan)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/javascript-scroll-bar-in-post/#post-1702874)
 * [http://kylefoleydesign.com/rbfgroup/css/jsScroller.js](http://kylefoleydesign.com/rbfgroup/css/jsScroller.js)
 * doesn’t seem to exist, is that file on the server?
 *  Thread Starter [someguy03](https://wordpress.org/support/users/someguy03/)
 * (@someguy03)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/javascript-scroll-bar-in-post/#post-1702875)
 * Woops, the file on the server didn’t have a capital S.
 * I fixed that, but the javascript still does_ not_ work.
 * Thanks for helping, hopefully I can get this solved.
 *  [jlevan](https://wordpress.org/support/users/jlevan/)
 * (@jlevan)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/javascript-scroll-bar-in-post/#post-1702879)
 * The javascript code should also be pulled out of the page content – insert it
   directly in the template files. If you look at your generated source, WordPress
   is scattering `<p>` tags throughout your script – a small snip:
 *     ```
       <script type="text/javascript">
       var scroller  = null;
       var scrollbar = null;</p>
       <p>window.onload = function () {
         scroller  = new jsScroller(document.getElementById("News"), 400, 180);
       ```
   
 *  Thread Starter [someguy03](https://wordpress.org/support/users/someguy03/)
 * (@someguy03)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/javascript-scroll-bar-in-post/#post-1702886)
 * Ah, that worked, thank you! I moved the rest of the javascript into the header.
   That fixed the javascript but the formatting was still getting messed up by the
   random line and paragraph breaks all over the HTML as well as you mentioned above..
   so I got the [Text Control Plugin](http://plugins.trac.wordpress.org/wiki/TextControl)
 * This allowed me to set the post to “no formatting” and removed the code WordPress
   was inserting.
 * Why does WordPress insert hidden HTML even when you are using the HTML tab?
 *  [jlevan](https://wordpress.org/support/users/jlevan/)
 * (@jlevan)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/javascript-scroll-bar-in-post/#post-1703042)
 * WordPress modifies the content of a post at several places.
 * The tinyMCE editor will add some tags, however, if you flip between the rich 
   editor and the HTML editor, you may notice that the rich editor will display 
   that a block of text is within a `<p>` tag while at the same time that is not
   shown in the HTML view – these it appears are just a sort of “this is how it 
   will be displayed after WP formats it” – these tags are not added to the post
   content at this point.
 * You should be able to see this if you save a post and view the post’s content
   in your database (through phpMyAdmin or however you view your database’s content)–
   the post’s content will lack any of these automatically inserted `<p>` tags.
 * These tags are added when you call your post content for display using `<?php
   the_content(); ?>` – WordPress looks at the content stored in the database and
   runs several filters over this content.
 * More info on this can be found here: [http://codex.wordpress.org/How_WordPress_Processes_Post_Content](http://codex.wordpress.org/How_WordPress_Processes_Post_Content)
 * As you can freely switch back and forth between the rich text editor and the 
   HTML editor, multiple times while editing a post, as well as the fact that the
   chosen method is tied to the user, and not the post itself (if you save a post
   while using the HTML editor, the next post you add/edit will also first display
   the HTML editor) – WP will not base how it formats a post on which editor you
   use. The editor choice is considered an author preference, not a format setting.

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

The topic ‘Javascript Scroll bar in post’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 12 replies
 * 3 participants
 * Last reply from: [jlevan](https://wordpress.org/support/users/jlevan/)
 * Last activity: [15 years, 6 months ago](https://wordpress.org/support/topic/javascript-scroll-bar-in-post/#post-1703042)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
