Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    revised image script

    i have decided to change the script up a little because the last one seemed to be a little buggy, but now i seem to be having some problems with this one. Like- I'll click the one to make the pic refresh every 30 seconds. It will refresh after 30 seconds, but then it just seems to stop working and will not refresh again.

    Code:
    <script language="JavaScript"><!--
    function pause(time) {
       setTimeout('refresh()',time);
    }
    
    function pause3() {
       document.images['cam'].onload = 'pause(3000)';
       setTimeout('refresh()',3000);
    }
    
    function pause10() {
       document.images['cam'].onload = 'pause(10000)';
       setTimeout('refresh()',10000);
    }
    
    function pause30() {
       document.images['cam'].onload = 'pause(30000)';
       setTimeout('refresh()',30000);
    }
    
    function refresh() {
       document.images['cam'].src = 'http://bst82551.ath.cx:8080/cam_1.jpg?' + Math.random();
    }
    
    function stop() {
       document.images['cam'].src = 'http://bst82551.ath.cx:8181/status/images/camoff.jpg';
       document.images['cam'].onload = '';
    }
    //--></script>
    here are the links i've created for this... and the image itself.

    Code:
    <font size=2>
    <a href="#" onclick="pause3()" title="3 seconds">3</a> - 
    <a href="#" onclick="pause10()" title="10 seconds">10</a> - 
    <a href="#" onclick="pause30()" title="30 seconds">30</a>
    </font>
    <br>
    <img src="http://bst82551.ath.cx:8080/cam_1.jpg" name="cam" onLoad="pause(3000)" onError="stop()">
    Brian
    Last edited by bst82551; 01-11-2005 at 12:33 AM.

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Maybe you need to cancel your timer with the clearTimeout() method...

  • #3
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    nothing happened when i did that. I inserted it into all logical places and tested it multiple times. Nothing changed.

    Brian

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,968
    Thanks
    0
    Thanked 236 Times in 233 Posts
    The correct way to set the onload handler is:

    document.images['cam'].onload = function(){pause(3000);}

    If there is no parameter on the onload function, it would have been like this:

    document.images['cam'].onload = pause;

  • #5
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    whoa, it worked!!!!

    Thank you so much, glenngv! I would definitely pay you for this if i had any money, haha.

    Brian

  • #6
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    by the way... brandoe85, you helped too. I had to use the clearTimeout() method to make what glenngv said in order to make the script function correctly. Thanks to you both.

    Brian

  • #7
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the finished product can be found here:

    http://bst82551.ath.cx:8181/cam/index.html

    If you'd like to see it. I probably won't have the cam on, but you can still look at the source, :-).

    Brian


  •  

    Posting Permissions

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