Javascript image counter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carl Gilbert

    Javascript image counter


    Hi
    I'm having problems with the following code.
    All I want to do is keep a counter on the page for every new image recieved
    without deviating from the "for" and "event".

    <OBJECT ID="CamImage1" WIDTH=352 HEIGHT=288
    CLASSID="CLSID: C79D3167-6133-4e7c-821C-5C114611022D"

    CODEBASE="http://www.ipvideocent er.com/components/CameraControl.c ab#VERSION=
    3,2,1,0">
    <PARAM NAME="URL"
    VALUE="http://130.241.175.79/axis-cgi/mjpg/video.cgi?resol ution=352x288">
    </OBJECT>

    <SCRIPT LANGUAGE="JavaS cript" FOR="CamImage1" EVENT="onNewIma ge()">
    var counter = 0;
    function countUp() {
    counter++;
    }
    document.write( counter);
    </SCRIPT>


    However this does not increment the counter and the adition of the
    document.write line removes the image from the page.
    Any help on this would be great. :)
    Regards, Carl.


  • neerolyte

    #2
    Re: Javascript image counter

    this should work:

    <OBJECT ID="CamImage1" WIDTH=352 HEIGHT=288
    CLASSID="CLSID: C79D3167-6133-4e7c-821C-5C114611022D"

    CODEBASE="http://www.ipvideocent er.com/components/CameraControl.c ab#VERSION=
    3,2,1,0">
    <PARAM NAME="URL"
    VALUE="http://130.241.175.79/axis-cgi/mjpg/video.cgi?resol ution=352x288">
    </OBJECT>
    <div id="display">0 </div>
    <script>var counter = 0;</script>
    <SCRIPT LANGUAGE="JavaS cript" FOR="CamImage1" EVENT="onNewIma ge()">
    counter++;
    display.innerHT ML = counter;
    </SCRIPT>


    it doesn't (the control seems to break the .innerHTML reference, this works
    though:


    <OBJECT ID="CamImage1" WIDTH=352 HEIGHT=288
    CLASSID="CLSID: C79D3167-6133-4e7c-821C-5C114611022D"
    CODEBASE="http://www.ipvideocent er.com/components/CameraControl.c ab#VERSION=
    3,2,1,0">
    <PARAM NAME="URL"
    VALUE="http://130.241.175.79/axis-cgi/mjpg/video.cgi?resol ution=352x288">
    </OBJECT>
    <div id="display">0 </div>
    <script>var counter = 0;</script>
    <SCRIPT LANGUAGE="JavaS cript" FOR="CamImage1" EVENT="onNewIma ge()">
    counter++;
    document.dis.co unt.value = counter;
    </SCRIPT>
    <form name="dis" method="post" action="">
    <input type="text" name="count">
    </form>


    Comment

    • neerolyte

      #3
      Re: Javascript image counter

      forgot to take out a line:


      <OBJECT ID="CamImage1" WIDTH=352 HEIGHT=288
      CLASSID="CLSID: C79D3167-6133-4e7c-821C-5C114611022D"

      CODEBASE="http://www.ipvideocent er.com/components/CameraControl.c ab#VERSION=
      3,2,1,0">
      <PARAM NAME="URL"
      VALUE="http://130.241.175.79/axis-cgi/mjpg/video.cgi?resol ution=352x288">
      </OBJECT>
      <script>var counter = 0;</script>
      <SCRIPT LANGUAGE="JavaS cript" FOR="CamImage1" EVENT="onNewIma ge()">
      counter++;
      document.dis.co unt.value = counter;
      </SCRIPT>
      <form name="dis" method="post" action="">
      <input type="text" name="count">
      </form>




      Comment

      Working...