Solved

Image Reload

Posted on 2004-04-19
9
628 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
 
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now