Results 1 to 2 of 2
  1. #1
    erwillie is offline Member
    Join Date
    Apr 2010
    Posts
    1
    Rep Power
    0

    Default show image that I refresh

    Hi everybody:

    I found in other forum the next code for refresh an image periodically:

    <SCRIPT LANGUAGE="JavaScript">
    <!-- hide

    // browser sniffer:
    browserVer = parseInt(navigator.appVersion);
    if (navigator.appName == "Microsoft Internet Explorer" && browserVer < 4)
    {
    alert("Internet Explorer 3 users need to hit 'Refesh' to update the image");
    }

    //this eliminates JavaScript error messages
    onError=null

    // The variables you need to change are: the filename of the picture,
    // the refresh rate, the expected time to download and further down,
    // the FORM ACTION (look for the ***).
    var picname = "/guarrada/Debug/foto.jpg"; // set this to the filename of your campicture
    var speed = 1; // "var speed" is the refresh rate adjustment in seconds
    var y = 0.75; // expected time to download the picture file. It MUST be
    // set at a smaller number than the "speed" variable!

    var x = speed; // current countdown
    var cachepic = new Image();

    function stopClock() {
    x = "00";
    }

    function startClock() {
    if (x != "00") {
    x = x - 1;
    if (x == y) {
    recache()
    }
    if (x <= 0)
    {
    reload()
    }
    timerID = setTimeout("startClock()", 1000);
    }
    }

    function recache() {
    var now = new Date();
    var camImg = picname + "?" + now.getTime();
    cachepic.src = camImg;
    }

    function reload() {
    document.images.campicture.src = cachepic.src;
    x = speed;
    }

    //end hide -->
    </SCRIPT>


    Now I want to show in a web the image that Iīm refreshing. I probe with the next but doesnīt work:


    <SCRIPT LANGUAGE="JavaScript">
    <!-- hide

    // browser sniffer:
    browserVer = parseInt(navigator.appVersion);
    if (navigator.appName == "Microsoft Internet Explorer" && browserVer < 4)
    {
    alert("Internet Explorer 3 users need to hit 'Refesh' to update the image");
    }

    //this eliminates JavaScript error messages
    onError=null

    // The variables you need to change are: the filename of the picture,
    // the refresh rate, the expected time to download and further down,
    // the FORM ACTION (look for the ***).
    var picname = "/guarrada/Debug/foto.jpg"; // set this to the filename of your campicture
    var speed = 1; // "var speed" is the refresh rate adjustment in seconds
    var y = 0.75; // expected time to download the picture file. It MUST be
    // set at a smaller number than the "speed" variable!

    var x = speed; // current countdown
    var cachepic = new Image();

    function stopClock() {
    x = "00";
    }

    function startClock() {
    if (x != "00") {
    x = x - 1;
    if (x == y) {
    recache()
    }
    if (x <= 0)
    {
    reload()
    }
    timerID = setTimeout("startClock()", 1000);
    }
    }

    function recache() {
    var now = new Date();
    var camImg = picname + "?" + now.getTime();
    cachepic.src = camImg;
    }

    function reload() {
    document.images.campicture.src = cachepic.src;
    x = speed;
    }

    //end hide -->
    </SCRIPT>

    <div id="imagen" >
    <%=image_tag("/guarrada/Debug/foto.jpg") %>
    </div>
    <body onload="startClock()">
    </body>


    Anyone can help me? I donīt know a lot of java and I donīt know how to show it correctly

    Thanks!!!!

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,307
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by erwillie View Post
    Anyone can help me? I donīt know a lot of java and I donīt know how to show it correctly
    That's not Java; it's Javascript; this is a Java forum, sorry.

    kind regards,

    Jos

Similar Threads

  1. image does not refresh-driving me crazy
    By jambon in forum AWT / Swing
    Replies: 1
    Last Post: 04-09-2010, 04:25 PM
  2. Replies: 0
    Last Post: 03-19-2010, 11:26 PM
  3. Show image on glasspane while mouse button is down
    By zweibieren in forum AWT / Swing
    Replies: 10
    Last Post: 09-12-2009, 06:29 AM
  4. Replies: 1
    Last Post: 08-25-2008, 08:48 PM
  5. Random Image on Refresh (FROM Folder not set number)
    By QuinnMal in forum Java Servlet
    Replies: 1
    Last Post: 07-06-2007, 07:27 PM

Posting Permissions

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