Solved

Image Reload

Posted on 2004-04-19
9
631 Views
Last Modified: 2008-03-17
Hello, i have the following code, it is reloading a picture every 45 seconds, the picture is cached on the server or local computer somehow, and i need this to refresh every time also.

<head>
<meta http-equiv="refresh" content="45">
<META HTTP-EQUIV="cache-control" CONTENT="no-cache">
<META http-equiv="Expires" content="0">
<title></title>
</head>

<body topmargin="0" leftmargin="0" style="background-color: #000000">

<img src="http://www.ktvq.com/q2news/public_html/webcam/webcam.jpg" width="705" height="533">
0
Comment
Question by:GBLX-Bill
  • 8
9 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 125 total points
ID: 10859254
<body topmargin="0" leftmargin="0" style="background-color: #000000"
  onload="document.images['webcam'].src='http://www.ktvq.com/q2news/public_html/webcam/webcam.jpg'+Math.random();" >

<img name="webcam"width="705" height="533" />
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 10859259
oops, typo.  Add a "?" after .jpg:

onload="document.images['webcam'].src='http://www.ktvq.com/q2news/public_html/webcam/webcam.jpg?'+Math.random();"
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 10859266
also add a space after the image name and before width:

<img name="webcam" width="705" height="533" />
0
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 
LVL 33

Expert Comment

by:knightEknight
ID: 10859283
adding a random number to the image URL will force the browser to reload it instead of getting it from the cache.
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 10859335
another way to do this -- if you are using a server script instead of just plain HTML:

  <meta http-equiv="refresh" content="45, url=http://www.yourserver.com/yourpage.asp?<%=rnd()%>" />

or

  <meta http-equiv="refresh" content="45, url=http://www.yourserver.com/yourpage.asp?<%=Math.random()%>" />

0
 

Author Comment

by:GBLX-Bill
ID: 10859629
so for the top example, im confused, can you re-list the final?
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 10859749
sure ... just make sure you name the image consistently in the name and in the onload handler:


<body topmargin="0" leftmargin="0" style="background-color: #000000"
  onload="document.images['webcam'].src='http://www.ktvq.com/q2news/public_html/webcam/webcam.jpg?'+Math.random();" >

<img name="webcam" width="705" height="533" />
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 10859759
(I named it "webcam" but you can name it what ever you want, just reference it consistently in the script.:)
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 10860429
another option is to use the current system time:

onload="document.images['webcam'].src='http://www.ktvq.com/q2news/public_html/webcam/webcam.jpg?'+new Date().getTime();"
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

770 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