Results 1 to 6 of 6

Thread: Web page coding help?

  1. #1
    Join Date
    May 2007
    Location
    Thomasville, GA
    Posts
    5,992

    Web page coding help?

    For you programming gurus out there:

    For several years, I've been displaying my shop cam on my website during times I'm out here. Now, I would like to display two cams on the same page and have them refresh occasionally. I found some Java code a few years ago that worked well for one image but have not been able to figure out how to make it work for two images.

    Here's the code I've been using:
    <script>
    var imgFresh = new Image();
    var imgNow;
    var imgSrc;

    function errHandler()
    {
    defaultStatus = "Failed";
    }

    function loadHandler()
    {
    defaultStatus = "Loading ...";
    document.images[imgSrc].src = imgNow;

    }

    function living(srcName,imgFile)
    {
    imgSrc = srcName;
    var now = new Date() ; now = "?"+ now.getTime();
    imgNow = imgFile + now;
    imgFresh.src = imgNow;
    imgFresh.onload=loadHandler;
    imgFresh.onerror=errHandler;
    setTimeout("living('" + srcName + "','" + imgFile + "')",5000);
    }

    </script>

    I've tried duplicating portions of the script and using subscripts to differentiate them. What should I be doing to the script? Or, is there a better way to do what I want.

    Thanks for your help.

    PS: Yeah, yeah. I know this is a woodworking forum but there seem to be some sharp computer folks on here.

    By the way, the software I'm using to control the cameras and FTP the jpg files is iSpy.
    Bill Arnold
    Citizen of Texas residing in Georgia.
    NRA Life Member and Member of Mensa
    My Weather Underground station

  2. #2
    Join Date
    Jun 2007
    Location
    Oceanside, So. Calif. 5 mi. to the ocean
    Posts
    4,944
    Hi,

    Regarding your PS: I'm not one of them.

    Enjoy,
    Jim
    First of all you have to be smarter than the machine.
    VOTING MEMBER

  3. #3
    Join Date
    May 2007
    Location
    Kansas City, Missouri
    Posts
    13,440
    Bill,

    On the onload event of your body tag, it looks like you're calling

    living("liveimg","shop_1.jpg");

    Looks like you should be calling that twice, but on the second call you need to call the name for the name attribute in the second IMG tag. Currently both images have the same value ('liveimg') in the name. Change teh second one to something like 'liveimg2' and for the second parameter of the living() call, pass the image name that should show in that second IMG

    living("liveimg","shop_1.jpg");living("liveimg2","shop_2.jpg");

    Hope that makes sense...if not I'll try to explain more.
    Darren

    To a small child, the perfect granddad is unafraid of big dogs and fierce storms but absolutely terrified of the word “boo.” – Robert Brault

  4. #4
    Join Date
    May 2007
    Location
    Kansas City, Missouri
    Posts
    13,440
    Body tag should read:

    HTML Code:
    <body vlink="#000080" bgcolor="#FFFFFF" alink="#000080" text="#000000" link="#000080" onload="living('liveimg','shop_1.jpg');living('liveimg2','shop_2.jpg');" bgproperties="FIXED">
    second image should be:

    HTML Code:
    <img border="1" alt="Cam 2 Loading..." name="liveimg2" src="shop_2.jpg">
    Last edited by Darren Wright; 08-30-2011 at 09:24 PM.
    Darren

    To a small child, the perfect granddad is unafraid of big dogs and fierce storms but absolutely terrified of the word “boo.” – Robert Brault

  5. #5
    Join Date
    May 2007
    Location
    Thomasville, GA
    Posts
    5,992
    Darren,

    Thanks for the code, but I'm still having an issue. The "onload" only seems to work with the last parameter called. Using the code as written, "image2" is the only one that changes. If I vary the code and place the "image1" function in the second position, then image1 changes as it should but image2 does not.
    Bill Arnold
    Citizen of Texas residing in Georgia.
    NRA Life Member and Member of Mensa
    My Weather Underground station

  6. #6
    Join Date
    May 2007
    Location
    Kansas City, Missouri
    Posts
    13,440
    change the comma between the two javascript calls to a semicolon:

    HTML Code:
    living('liveimg','shop_1.jpg'),living('liveimg2','shop_2.jpg')
    to

    HTML Code:
    living('liveimg','shop_1.jpg');living('liveimg2','shop_2.jpg')
    Javascript uses semicolons to separate function calls.
    Last edited by Darren Wright; 08-31-2011 at 04:27 PM.
    Darren

    To a small child, the perfect granddad is unafraid of big dogs and fierce storms but absolutely terrified of the word “boo.” – Robert Brault

Similar Threads

  1. I used to use this URL for my home page
    By Bart Leetch in forum Off Topic Discussion
    Replies: 3
    Last Post: 11-17-2012, 02:06 AM
  2. I have been setting up a new page
    By Dave Hawksford in forum Off Topic Discussion
    Replies: 16
    Last Post: 03-09-2011, 06:30 PM
  3. Looking for a page from Woodsmith #136
    By Jiggs Elphison in forum Off Topic Discussion
    Replies: 0
    Last Post: 07-03-2009, 12:25 AM
  4. Welcome Bruce Page.
    By Don Baer in forum Welcome and Introductions
    Replies: 13
    Last Post: 11-27-2006, 01:54 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •