Link to home
Start Free TrialLog in
Avatar of LeeOl
LeeOlFlag for United States of America

asked on

Hen cam motion on website page

We have two camera on our backyard hens. They are set to refresh every 3 seconds. One shows "outside" view. One shows "nest boxes". We have gotten the "outside" to refresh but there seems to be a conflict in the javascript, not allowing the "nest boxes" to refresh. We are total amateurs at code, so patience is required.

You can see the website at backyardhencam.com.
Avatar of mmarx82
mmarx82
Flag of United States of America image

Copy and paste my code in, i tested it and it's working, if you add more cameras to make them all refresh just change the refresh function to handle the new camera.
<p>
<script language="javascript"> 
var refreshrate=3;                 //SECONDS BETWEEN REFRESH
var image="http://hencam1.viewnetcam.com:5002/SnapshotJPEG?Resolution=640x480&amp;Quality=Standard";     //IMAGE NAME
var imgheight=480;                   //IMAGE HEIGHT
var imgwidth=640;                 //IMAGE WIDTH
document.write('<IMG SRC="'+image+'" ALT="Chicken Coup" NAME="pic" ID="pic" WIDTH="'+imgwidth+'" HEIGHT="'+imgheight+'" BORDER="0">');

</script>
</p>
<h3>NESTBOXES</h3>
<h4>If screen is dark, shhhhhhh&#8230;hens are sleeping.</h4>
<p>
<script language="javascript"> 
var refreshrate2=3;                 //SECONDS BETWEEN REFRESH
var image2="http://hencam2.viewnetcam.com:5003/SnapshotJPEG?Resolution=320x240&amp;Quality=Standard";     //IMAGE NAME
var imgheight2=480;                   //IMAGE HEIGHT
var imgwidth2=640;                 //IMAGE WIDTH
document.write('<IMG SRC="'+image2+'" ALT="Nestboxes" NAME="pic2" ID="pic2" WIDTH="'+imgwidth2+'" HEIGHT="'+imgheight2+'" BORDER="0">');

function refresh(){
document.images["pic"].src=image+"?"+new Date();
document.images["pic2"].src=image2+"?"+new Date();
setTimeout('refresh()', refreshrate2*1000);}

if(document.images)window.onload=refresh;

</script></p>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of mmarx82
mmarx82
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LeeOl

ASKER

Can't wait to see if this works. Thank you!

It will take me a little time to do this. I'm very inexperienced at this code thing. Will let you know as soon as I try it.
Avatar of LeeOl

ASKER

Wow! I got my son to paste your code in for me and it works beautifully! Can't thank you enough for your expertise!
Avatar of LeeOl

ASKER

I can't believe that something I've worked on for two months was solved in less than an hour! Amazing!
Your very welcome!
BTW, you may want to check into adding Google Analytics to your website. It will tell you where your users are coming from, how many hits your getting a day, how you stack up against other websites and a whole slew of other useful data. Not to mention it's free, you just drop a bit of code they give you onto the end of your webpage and your ready. Usually updates every 24hrs.
 
http://www.google.com/analytics/tour.html