Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Setting A Certain Delay

  1. #1
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Setting A Certain Delay

    I need a function that will reload a page inside an iframe a number of times.
    Example.
    There is a form that has 1 input box and a button so I enter 10 in the box and click the button then for example a certain page will reload 10 times inside the iframe.
    I was able to do that but the problem is i can't set it to wait for the page to load first, secondly i want it to reload the page as soon as the first part loads not the whole of it.

    Thanks and please help
    Here's my code
    PHP Code:
    <script type="text/javascript">
    var 
    0;
    function 
    StartRefresh(){
        
    t;
        if(
    == document.form.how_many.value) {        
            
    counter.innerHTML="Finished";
        } else {
            
    += 1;
            
    counter.innerHTML=t;
            
    document.getElementById('refreshed').src 'example.com';
        }              
    }
    </script>
    <FORM NAME="form">
    # of Times?<INPUT TYPE="text" name="how_many"><br>
    <br>
    <INPUT TYPE="button" VALUE="Start" onClick="StartRefresh()">
    <span id="counter"></span>
    <iframe id="refreshed" height="100px" align="left" width="100px" frameborder=0 marginwidth=0 marginheight=0 src=""></iframe>    
    </FORM> 
    using settimout or setinterval will make it wait for a specified amount of time and i don't want that I want it to reload as soon as the page starts to reload

  2. #2
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    Loop it:

    PHP Code:
    <script type="text/javascript">
    function 
    StartRefresh(){
    for(
    0document.form.how_many.valuei++) {        
            
    document.getElementById('counter').innerHTML=i;
            
    document.getElementById('refreshed').src 'example.com';
    }
    document.getElementById('counter').innerHTML="Finished";             
    }
    </script>
    <FORM NAME="form">
    # of Times?<INPUT TYPE="text" name="how_many"><br>
    <br>
    <INPUT TYPE="button" VALUE="Start" onClick="StartRefresh()">
    <span id="counter"></span>
    <iframe id="refreshed" height="100px" align="left" width="100px" frameborder=0 marginwidth=0 marginheight=0 src=""></iframe>    
    </FORM> 
    -magicyte

  3. #3
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well strangely it hits finished in a second so it doesn't wait for the page to finish or even start refreshing

  4. #4
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    It's supposed to. Do you want it to wait however many seconds?

    -magicyte

  5. #5
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Dude i don't want it to do it instantly neither wait a certain number of seconds i want it to wait for the iframe to finish refreshing before it starts the next refresh. Because some people may have a fast connection and some people have slow ones so I can't give a certain number of seconds.
    btw I'm no newbie or anything in javascript it's just that thing that's hard :/

  6. #6
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    Impossible.

    -magicyte

  7. #7
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That's what I thought, anyway I thought of using interval and make each user select his own interval time

  8. #8
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    Do you want to do that? I'd be glad to code you something.

    -magicyte

  9. #9
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    lol i did it already :P as I said i'm no noob =D
    Anyway i thought about it and probably the only way to do it is use the onChange because I tried it and it waits for the page to load =D

  10. #10
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    But that would make it go on forever
    Edit: actually not :P

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
  •