Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Image Reload

Posted on 2004-04-19
9
Medium Priority
?
645 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 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Technology Partners: 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!

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…

783 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