Solved

ONLOAD problem

Posted on 1998-09-02
5
329 Views
Last Modified: 2010-04-09
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>
0
Comment
Question by:rabbitears
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
jbirk earned 50 total points
ID: 1837283
Yes there is a way, and it would involve ising JavaScript only instead of the refresh meta tag.  Your would add this to your function:
if (x<=0)
 history.go(0);
That should do it for you!
I will post the entirely new and changed code in a minute here.
-Josh

0
 
LVL 8

Expert Comment

by:jbirk
ID: 1837284
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>
0
 

Author Comment

by:rabbitears
ID: 1837285
will this work on any browser?
0
 

Author Comment

by:rabbitears
ID: 1837286
will this work on any browser?
0
 
LVL 8

Expert Comment

by:jbirk
ID: 1837287
Yes this will work in all javascript enabled browsers!
-Josh
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now