Home arrow JavaScript arrow Page 3 - Creating a Scrolling Navigation Bar Effect with CSS and JavaScript
JAVASCRIPT

Creating a Scrolling Navigation Bar Effect with CSS and JavaScript


Welcome to the third part of a four-part series that shows you how to build collapsible navigation bars with CSS and JavaScript. In this part, you'll learn how to combine the functionality of the Prototype and Scriptaculous libraries to construct a pretty useful scrolling navigational bar.

Author Info:
By: Alejandro Gervasio
Rating: 3 stars3 stars3 stars3 stars3 stars / 2
October 05, 2009
TABLE OF CONTENTS:
  1. · Creating a Scrolling Navigation Bar Effect with CSS and JavaScript
  2. · Building the dynamic navigation bar
  3. · Adding a scrolling effect with the Scriptaculous DHTML framework
  4. · Finishing the dynamic navigation bar

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Creating a Scrolling Navigation Bar Effect with CSS and JavaScript - Adding a scrolling effect with the Scriptaculous DHTML framework
(Page 3 of 4 )

As I explained, my intention is to teach you how to construct a navigation bar that can be hidden and displayed on a web page by way of a scrolling effect. Since I showed you the navigation bar's markup in the previous section, I'm going to incorporate that effect into the bar in this one. 

Please examine the following JavaScript code. It implements the scrolling effect through use of the Scriptaculous “Effect.toggle()” method:

// display/hide navigation bar


function toggleNavBar(){

new Effect.toggle('navbar','slide');

}

// initialize navbar switcher

function initializeElement(){

Event.observe($('switcher'),'click',toggleNavBar,false);

}

Event.observe(window,'load',initializeElement,false);

Actually, the above JavaScript snippet is all that you need to turn the static navigation bar into a dynamic web interface that can be enabled and disabled via a scrolling effect.

In this case, I simply used the Scriptaculous’ toggle effect to perform the scroll, which will be fired up each time the switcher is clicked by a user. See how easy it is to construct a dynamic bar by using the Scriptaculous framework? I guess you do!

Nonetheless, if you’re like me, then you’ll want to see how the JavaScript code can be linked with the structural markup corresponding to this navigational bar. Therefore, in the next section I’ll be including the complete source code of this web application in a single file.

Click on the link below and keep reading.


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials