views:

166

answers:

2

Hey, okay as I said in the title I already got a working fake progressbar.

<html>
<head>
    <style type="text/css">
        #progress-bar-wrapper
        {
      width: 500px;
      height: 2px;
        }

        #progress-bar
        {
                background-color: #a1cee8;
                width: 100%;
                height: 100%;
        }
    </style>

    <script type="text/javascript" src="jquery-1.3.2.min.js"></script>
    <script type="text/javascript">
        $(function() { animateProgressBar() });

        function animateProgressBar()
        {
                $("#progress-bar")
                .css("width", "0%")
                .animate(
                {
                        width: "100%"
                },
                1550, //Speed of loading bar
                animateProgressBar);
        }
    </script>
</head>
<body>
    <div id="progress-bar-wrapper">
        <div id="progress-bar"></div>
    </div>
</body>
</html>

This progressbar is being put in a pre-loader-site and what I want it to do is that once it reaches 100%, it must stop and then reload/redirect the user to the next site..

I have this idea in mind, but I guess it has to be changed a bit in order to be applied: Progressbar loads, reaches 100% (this happens succesfully with the code provided above), however, it must stop at 100%. AND when it does, it must load an immediate redirection to the next site.

Hope everything is clear, thank you very much! Chris

A: 

Does one of the cookie cutter preloaders work for you?

carl
the "preloadit" (http://www.dynamicdrive.com/dynamicindex4/preloadit.htm) from dynamicdrive.com can be somewhat modyfied so that it fits what i am looking for.. but, I wonder, is it that hard to add something to the code I provided above to make what I ask?thank you though, it's really appreciated, and if what I just asked above can't be answered, I will definitely use that cookie-cutter-preloader.Chris
Hobhouse
Not really (mostly because there isn't anything too specific there).You literally just need to preload images using your favorite preload technique (CSS bg, Image object, etc), and each time an image loads, advance the progress bar. At 100%, redirect.
carl
A: 

Okay, figured this out with the support of a friend:

<script type="text/javascript">
var x=0;
//var y=5;
window.onload=progress();

function progress(){
    var timer;

    if(x<100){
        x+=1;
        document.getElementById('progressbar').style.width=x+'%';            
        timer=setTimeout('progress()',-40);
    }else{
        clearTimeout(timer);
        location.href='http://siteexample.com/index.html';
    }
}
</script>

The variable x has a default value of 0. windows.onload launches the progress, the bar fills itself according to the if-statement that it's <100 with x+=1 (this allowed me to imitate the smooth JQuery-animateProgressBar effect). The next two lines are just about the bar itself (getElementById looks for the CSS ID called 'progressbar' and setTimeout is just the time in ms between one call and the other)

Then, when it's bigger than 100 (else, x<100) the timer is cleared and a new location is loaded location.href='http://siteexample.com/index.html.

Hope it's useful to someone else, too. Chris (the commented var y=5 is still for testing; i'm trying to create a slowing-down effect on the progressbar.)

cr0z3r