HTML
  Home arrow HTML arrow Page 3 - How to Create a Dynamic HTML Navigation Pa...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
HTML

How to Create a Dynamic HTML Navigation Page
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 23
    2004-09-07

    Table of Contents:
  • How to Create a Dynamic HTML Navigation Page
  • Web Animation Doesn't Always Mean Flash
  • Subroutines
  • The Remaining Subroutines
  • Wrap'n it Up
  • Images to Use

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    How to Create a Dynamic HTML Navigation Page - Subroutines


    (Page 3 of 6 )

    Surprisingly, you need to write a total of thirteen subroutines to make it happen: eight onclick events (two for each directional button), plus five additional sub's to control the image movement. There are four global variables that are used throughout the script to control the image animation. They need to be global because each of them is accessed by two separate subroutines, so they need to be declared at the start of the script:

    dim leftButtonDown
    dim upbuttonDown
    dim rightButtonDown
    dim downButtonDown
    dim animator

    The first four are switches that are set to either 1 or 0 and are 'switched' by various mouse events. The reason you need four of them is that the script seems to get a little confused if you use just one, and the movement of the central image is a little irrational. Try using just one switch and see what happens.

    Next you need to script the onclick events, two for each of the directional control buttons:

    sub buttonLeft_onMouseDown
     animator=window.setInterval("flyLeft", 10)
     leftButtonDown=1
    End sub
    sub buttonLeft_onMouseUp
     window.clearInterval(animator)
     leftButtonDown=0
    end sub

    The mouseDown event initiates the setInterval method, which take a subroutine name and an integer as its argument, and assigns this to a variable, in this case 'animator'. The setInterval method is used to repeat a subroutine for a specified number of milliseconds, so what we're telling the script to do is execute the flyLeft function repeatedly for 10 milliseconds. It is this that produces the smooth animated movement of the central image, as you'll see when the file is finished. The subroutine also sets the leftButtonDown switch to on. We could simply call the subroutine that moves the central image instead of using the animator, but this way, users of your site would need to repeatedly click the directional button to move the image. 

    The mouseUp event uses the clearInterval method to stop the animation and takes simply the variable name assigned to setInterval as an argument. It also switches leftButtonDown back off. Without the mouseUp subroutine, the central image you continue to move after the user had stopped clicking.

    In using these two subroutines you'll find that the images scrolls across the screen while the directional button is down, and stops as soon as the button is released. After writing the remaining OnClick subroutines, you should end up with a block of code like this:

    sub buttonLeft_onMouseDown
      animator=window.setInterval("flyLeft", 10)
      leftButtonDown=1
     End sub
     sub buttonLeft_onMouseUp
      window.clearInterval(animator)
      leftButtonDown=0
     end sub
     sub buttonUp_onMouseDown
      animator=window.setInterval("flyUp", 10)
      upButtonDown=1
     End sub
     sub buttonUp_onMouseUp
      window.clearInterval(animator)
      upButtonDown=0
     end sub
     sub buttonRight_onMouseDown
      animator=window.setInterval("flyRight", 10)
      rightButtonDown=1
     End sub
     sub buttonRight_onMouseUp
      window.clearInterval(animator)
      rightButtonDown=0
     end sub
     sub buttonDown_onMouseDown
      animator=window.setInterval("flyDown", 10)
      downButtonDown=1
     End sub
     sub buttonDown_onMouseUp
      window.clearInterval(animator)
      downButtonDown=0
     end sub

    More HTML Articles
    More By Dan Wellman


       · It would be great if you provided a working example so we could see how it works...
       · Maybe someone might find this a good article but it lacks detail and really doesn't...
       · Agreed. Thats the first thing I look for in a tutorial, so I can understand what...
       · Generally most browsers nowadays support VB script, however.. this is all written in...
       · I created a web page and copied all the graphics. When I open this in IE 6.0 with XP...
       · Please correct me if I'm mistaken, but only ONE browser supports VBscript - yes I...
       · I'm surprised that this script didn't work for anyone running IE6 on XP Pro, that is...
       · Youve got very useful site. It really helped me. Thanks.
       · Youve got a great site. I found it very useful.
     

    HTML ARTICLES

    - Completing Construction of a Database Form w...
    - Maximizing and Restoring Images in a Tabular...
    - Building the Recordset for an HTML Database ...
    - Laying Out a Database Form with HTML
    - Tabular Database Form Functions with HTML
    - Tabular Database Forms with HTML
    - Using the Find Functions for HTML Database F...
    - Sorting for Database Forms with HTML
    - Edit and Other Database Form Functions with ...
    - More Database Form Functions with HTML
    - Database Form Functions with HTML
    - Using the HTML Table Element as a Recordset
    - Building Single Row Database Forms with HTML
    - Introduction to Database Forms with HTML
    - Another Look at Animation of Geographical Ma...






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT