Solved

ONLOAD problem

Posted on 1998-09-02
5
336 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

717 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