JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 20th, 2013, 08:01 AM
actioman actioman is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 4 actioman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 50 m 2 sec
Reputation Power: 0
Question How refresh a item in website

Hi there,

I am a passionate weather and I'm creating a website for my weather station.
Because I am a beginner in this world of design pages for websites I'm learning as I go creating pages.
Now I wanted to create a page with the radar image from my area. But that was updated by the minute.

What complicates me more is that the image is in the following direction:
www. meteoelvas . com / RadarIM.php. And the script I'm testing does not work. Loads the image initially, but then will not upgrading to the most recent image, as you can see here:
www. meteoelvas . com / wxradar.php.

This is the code I am using:
Code:
<script type="text/javascript">
// <![CDATA[ 
var refreshrate = 60; // seconds between refresh
var image = "RadarIM.php"; // image name
var imgwidth = 600; // image width
var imgheight = 600; // image height
var imgalt = "Radar IM"; 
function refresh() { document.images["pic"].src = image + "?" + new Date(); setTimeout('refresh()', refreshrate * 1000); } document.write('<img src="' + image + '" alt="' + imgalt + '" name="pic" id="pic" width="' + imgwidth + '" height="' + imgheight + '" style="border: none;" />'); if(document.images)window.onload=refresh; // ]]> </script>


My thanks for possible helps.

Reply With Quote
  #2  
Old February 20th, 2013, 09:12 AM
web_loone08's Avatar
web_loone08 web_loone08 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2008
Posts: 605 web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 16 h 30 m 44 sec
Reputation Power: 69
You need to give the image a unique query (to prevent image cache); as you were trying to do, but you were using the Date Object. So I replaced it with a number.

Code:
<script type="text/javascript">
// <![CDATA[ 
var refreshrate = 60; // seconds between refresh
var image = "RadarIM.php"; // image name
var imgwidth = 600; // image width
var imgheight = 600; // image height
var imgalt = "Radar IM";
var refreshID = 0;
refreshrate = refreshrate * 1000;
function refresh()
{
refreshID++;
document.images["pic"].src = image + "?rid=" + refreshID; 
setTimeout('refresh()', refreshrate);
}
document.write('<img src="' + image + '" alt="' + imgalt + '" name="pic" id="pic" width="' + imgwidth + '" height="' + imgheight + '" style="border: none;" />'); 
window.onload = function() {
refresh();
}
// ]]>
</script>
Comments on this post
actioman agrees!

Last edited by web_loone08 : February 20th, 2013 at 03:54 PM.

Reply With Quote
  #3  
Old February 20th, 2013, 12:54 PM
actioman actioman is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 4 actioman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 50 m 2 sec
Reputation Power: 0
web_loone08 many many thanks!!!

So simple, but for those who do not know becomes complicated.

And what the asks the code now? an image whatsoever, in a given time interval?

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > How refresh a item in website

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap