Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Image Refresh

Recommended Posts

Just to tidy up kshan's code

	  <img src="image_name.jpg" width="275" height="200" border="1" name="refresh">	  <script language="JavaScript" type="text/javascript">	  <!--	  var t = 120 // interval in seconds	  function Start() {	  document.images["refresh"].src = document.images["refresh"].src+"?"+Math.random()	  setTimeout("Start()", t*1000)	  }	  Start();	  // -->	  </script>

Hello there,

I tried using the above code to refresh an image in my webpage. It does not work. It loads the image only once and stays put. Am I doing something wrong? Could someone kindly help me?

Thanks.

<!DOCTYPE html><%@ page import="java.util.*" %><%@ page import="java.util.Calendar" %><%@ page import="java.io.File" %><%@ page import="java.io.*" %><%@ page language="java" import="java.util.*"%> <HTML><head> </head> <BODY><img src="C:\\WebDev\\uploads\\image\\image.jpg" border="1" name="track"><script language="JavaScript" type="text/javascript">function refreshImage(){  image = "C:\\WebDev\\uploads\\image\\image.jpg"  document.images["track"].src = image;  System.out.println("Cycle\n");  setTimeout("refreshImage()", 5000);}refreshImage();</script></BODY></HTML>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.