Results 1 to 2 of 2
Thread: show image that I refresh
- 04-29-2010, 02:57 PM #1
Member
- Join Date
- Apr 2010
- Posts
- 1
- Rep Power
- 0
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!!!!
- 04-29-2010, 03:23 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,406
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
image does not refresh-driving me crazy
By jambon in forum AWT / SwingReplies: 1Last Post: 04-09-2010, 04:25 PM -
Image does not show up when using 'setRowGroup'.
By sdsdsd in forum JDBCReplies: 0Last Post: 03-19-2010, 11:26 PM -
Show image on glasspane while mouse button is down
By zweibieren in forum AWT / SwingReplies: 10Last Post: 09-12-2009, 06:29 AM -
How to show pixel Coordinate and RGB value when mouse is tracking over an image
By Mazharul in forum Java 2DReplies: 1Last Post: 08-25-2008, 08:48 PM -
Random Image on Refresh (FROM Folder not set number)
By QuinnMal in forum Java ServletReplies: 1Last Post: 07-06-2007, 07:27 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks