Solved

ONLOAD problem

Posted on 1998-09-02
5
334 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Insert Button on a table 16 45
Using HTML5 and CSS How to place one element in front of another elemen 7 45
Triple line in an alert message 4 19
aria difference 2 12
Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

685 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