Advanced Search

Results 1 to 6 of 6

Thread: Event-based Progress Bar Help

  1. #1
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Event-based Progress Bar Help

    In the two Progressing the progress bar examples:

    I can get the progress bar to work when I use-
    <a href="javascript:incrCount(5)">Increase bar by 5%</a>

    but, if I try-
    <script>setCount(50) //set bar to 50%</script>
    It displays the bar at 0%, not at 50%.

    I've also tried-
    <img src="myImage.jpg" height="2000" width="1000" onLoad="setCount(50)">
    Which also displays the bar at 0%, not at 50%.

    What am I doing wrong?
    Last edited by dtp; 04-15-2005 at 08:59 PM.

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by dtp
    What am I doing wrong?
    I can't imagine. The incrCount and decrCount function both call setCount, so replacing one of those working calls with a setCount call should work just fine.

    Is there anything you're not telling us, such as error messages, etc.?

    In future, please link to the script in question.

    Mike

  3. #3
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Progress Bar Help

    No, there are no error messages.

    Here is my test html that points to the "percent_bar.js".

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    <title></title>
    </head>
    <body>
    <script language="javascript" src="percent_bar.js"></script>
    <!--
    <a href="javascript:incrCount(25)">Click here to increment the bar by 25%</a>

    <img src="myImage.jpg" height="2000" width="1000" onLoad="setCount(50)" >
    -->
    <script>setCount(50)</script>
    </body>
    </html>

  4. #4
    Join Date
    Aug 2004
    Location
    Brighton
    Posts
    1,563
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by dtp
    <script language="javascript" src="percent_bar.js"></script>
    I'll just chip in here and say that as it stands, that's a violation of script usage terms. It should look like:

    <script type="text/javascript" src="percent_bar.js">

    /*
    Event-based progress bar- By Brian Gosselin at http://scriptasylum.com/bgaudiodr
    Featured on DynamicDrive.com
    For full source, visit http://www.dynamicdrive.com
    */

    </script>
    cr3
    A retired member, drop me a line through my site if you'd like to find me!
    cr3ative media | read the stickies

  5. #5
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by dtp
    No, there are no error messages.
    Unless you've made some fairly significant modifications to the stock script, I certainly find errors in Firefox.

    <script>setCount(50)</script>
    Missing type attribute aside, the script initialises the progress bar once the document has finished loading. Your call above will occur before this initialisation process is complete, thereby causing an error. If you want to start the bar at a value other than 0%, either call setCount from a load event listener, or modify the loaded variable declaration that appears after the "DO NOT EDIT BEYOND THIS POINT" comment.

    Mike

  6. #6
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Progress Bar

    Yes, in its current "test" faze, I eliminated the 'rights' to simplify the code for this example. The 'rights' will be properly added when it goes live.

    I'm thinking the problem might be inherent to some Event Handlers. I can get-
    <img src="myImage.jpg" height="2000" width="1000" onLoad="setCount(50)" >
    to work if I replace it with onClick or onMouseOut, but not onLoad, or onBlur, or onChange.

    I know the 'onLoad' event handler is associated with both the 'window(frame)' and the 'image' object. Ideally, I'm looking for a triggered event other than a mouse triggered event.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •