/    Sign up×
Community /Pin to ProfileBookmark

Help with a refresh script!!

Ok, I’m trying to create a site where every 5-10 seconds, an image is
refreshed. I have tried the basic refresh page, but that
just gets to be a pain in the a$$. I have a webcam set up in the
basement, and it captures a clip every few seconds, then it uploads it
to my server. I have tried banner rotation scripts, and they all
preload the images, so I keep getting the same 3-4 images repeating,
even though those images are no longer on my server. I suppose they
are in the cache of the user. How do I do this, if at all possible. I have seen something like this on a local radio show’s website, but they have since taken that down..

Thanks for any input.

James W.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@SamSep 02.2003 — <i>
</i>&lt;body onload="timeswitch()"&gt;

and in the <head>
<i>
</i>&lt;script type="text/javascript"&gt;
var switchtime=0;
function timeswitch()
{
switchtime = setTimeout('swap()',10000)
}
function swap()
{
Image img=new Image();
img.src='images/webcam.jpg';
timeswitch();
}
&lt;/script&gt;

This should work as long as webcam.jpg continuously overwrites itself
Copy linkTweet thisAlerts:
@MyBandwidthSep 02.2003 — Here is a different example that will work on one condition. That your web cam image that gets automatically uploaded to your server overwrites the previous image using the exact same image file name; like WebCamImage.gif

The script uses an OnMouseMove function instead of a timed Refresh for the whole page. Every time the mouse moves the page makes a call to the image. You could remove the OnMouseMove from the BODY and put it in the Image tag too. If you do the mouse will have to move over the image to see the change.

The other post from samij586 actually answers your question correctly and is better, simpler code, I just wanted to post an alternative.

////////// Load the following script in to your HEAD

<HEAD>

<SCRIPT Language="javascript">

<!--

function JM_preloadImages() { //v3.0

var d=document; if(d.images){ if(!d.JM_p) d.JM_p=new Array();

var i,j=d.JM_p.length,a=JM_preloadImages.arguments; for(i=0; i<a.length; i++)

if (a[i].indexOf("#")!=0){ d.JM_p[j]=new Image; d.JM_p[j++].src=a[i];}}

}



function AutoImgRestore() { //v3.0

var i,x,a=document.Jere_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function AutoFind(n, d) { //v4.0

var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=AutoFind(n,d.layers[i].document);

if(!x && document.getElementById) x=document.getElementById(n); return x;

}



function AutoLoad() { //v3.0

var i,j=0,x,a=AutoLoad.arguments; document.Jere_sr=new Array; for(i=0;i<(a.length-2);i+=3)

if ((x=AutoFind(a[i]))!=null){document.Jere_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}

//-->

</SCRIPT>

</HEAD>





////////// add the following code to your BODY tag



<BODY onMouseMove="AutoLoad('ImageName','','WebCamImage.gif',0)">





////////// Add the image source in the BODY part of your page



<img src="WebCamImage.gif" width="300" height="250" name="ImageName">
Copy linkTweet thisAlerts:
@jwilkinson1977authorSep 03.2003 — Alright, I put this in the body tag
[i]Originally posted by samij586 [/i]

[B]<i>
</i>&lt;body onload="timeswitch()"&gt;
[/B]
[/QUOTE]

And this in the head
[i]Originally posted by samij586 [/i]

[B]<i>
</i>&lt;script type="text/javascript"&gt;
var switchtime=0;
function timeswitch()
{
switchtime = setTimeout('swap()',10000)
}
function swap()
{
Image img=new Image();
img.src='images/webcam.jpg';
timeswitch();
}
&lt;/script&gt;

This should work as long as webcam.jpg continuously overwrites itself [/B][/QUOTE]

It isn't working right..

[URL=http://wilkinsoncafe.com/test.html]This is just a test page with the image[/URL]

The only thing I changed was the path to the image file. (the name is actually correct) Please Check out the source, make sure i didn't screw it up somehow..

Thanks
Copy linkTweet thisAlerts:
@jwilkinson1977authorSep 03.2003 — i forgot, webcam.jpg does overwrite itself..
×

Success!

Help @jwilkinson1977 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...