Solved

Image Reload

Posted on 2004-04-19
9
634 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
[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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article discusses four methods for overlaying images in a container on a web page
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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

756 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