Menu

Webcam on a webpage...

2003-01-21
2013-03-22
  • Pavel Denissov

    Pavel Denissov - 2003-01-21

    This is the main reason most of us have a webcam - to setup
    a webpage where visitors cam umm... observe us. *grin*
    Anyway, I'm guessing I'm not the only one who doesn't have
    the processingpower needed to provide more than 1 fps or
    choose to have "slow" updates for any other reason.

    The solution would then be either to have user to refresh the
    webpage manually or include a meta-refresh tag, so that the
    page reloads automagicaly. Well, I thought about it and
    found that refreshing the whole page is too slow (especially
    if you include the picture in some large webpage, like me
    http://www.df.lth.se/~ryssen/mysite/main.html\).

    So I've written a simple javascript that will reload the picture
    only. If anyone is interested, I'll put it up online.

    Cheers!

    // Storm

     
    • Char Reitsma

      Char Reitsma - 2005-02-01

      Or, you can just use this script (provided it displays properly).  You probably want to set the refresh time to a little less than you have the server refreshing at.

       
    • Char Reitsma

      Char Reitsma - 2005-02-01

      Forgot to paste it, here it is:

      <script language="JavaScript"><!--
      function refreshIt() {
         if (!document.images) return;
         document.images['myCam'].src = 'cam/webcam.jpg?' + Math.random();
         setTimeout('refreshIt()',900); // refresh every .9 secs
      }
      //--></script>

       
    • Char Reitsma

      Char Reitsma - 2005-02-01

      one last thing, you need to change cam/webcam.jpg to the location of your image file, and you need to add name="myCam" to your <img src="cam/webcam.jpg"> tag, so it would look like:

      <img src="picture/location.jpg" name="myCam">

      and onLoad=" setTimeout('refreshIt()',900)" to the body tag - so it's like this:

      <body onLoad=" setTimeout('refreshIt()',900)">

       

Log in to post a comment.

MongoDB Logo MongoDB