?
Solved

Image Reload

Posted on 2004-04-19
9
Medium Priority
?
643 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 500 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
Independent Software Vendors: 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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…
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
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 …

719 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