Link to home
Start Free TrialLog in
Avatar of rabbitears
rabbitears

asked on

ONLOAD problem

is there a way to make the counter not start counting until the picture loads? i'm working on a web cam, but if load three seperate jpgs and only have a 15 second count, the page will try to refresh before the pics come down.. on a slow connection of course..

here's waht i'm doing..

<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta http-equiv="Refresh" content="15">
<title>Non-Java test</title>
</head>

<body ONLOAD="startClock()">

<img src="alex.jpg" ALT="SpyCam Video Window" width="320" height="240">

<img src="sloan.jpg" ALT="SpyCam Video Window" width="320" height="240">

<form NAME="form1">
<P>This page will reload in  
<INPUT TYPE="text" NAME="clock" SIZE="3" VALUE=""> seconds.
</form>

<SCRIPT LANGUAGE="JavaScript">
    <!-- HIDING
    var x = 16
    var y = 1
    function startClock(){
        x = x-y
        document.form1.clock.value = x
        timerID = setTimeout("startClock()", 1000)
          }
    // END HIDING -->
</SCRIPT>

      
            


</body>
</html>
ASKER CERTIFIED SOLUTION
Avatar of jbirk
jbirk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jbirk
jbirk

OK, here is the new code.  Note that I changed some of the code a little...  This doesn't actually change the functionality, but I think it's nicer this way (just my manner of style I guess)

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Non-Java test</title>
</head>
<body ONLOAD="startClock()">
<img src="alex.jpg" ALT="SpyCam Video Window" width="320" height="240">
<img src="sloan.jpg" ALT="SpyCam Video Window" width="320" height="240">
<form NAME="form1">
<P>This page will reload in  
<INPUT TYPE="text" NAME="clock" SIZE="3" VALUE=""> seconds.
</form>
<SCRIPT LANGUAGE="JavaScript">
<!-- HIDING
var x = 15;
function startClock()
 {if (x<=0)
   history.go(0);
  document.form1.clock.value = x--;
  timerID = setTimeout("startClock()", 1000);
 }
// END HIDING -->
</SCRIPT>
</body>
</html>
Avatar of rabbitears

ASKER

will this work on any browser?
will this work on any browser?
Yes this will work in all javascript enabled browsers!
-Josh