Results 1 to 5 of 5

Thread: Javascript not working in Internet Explorer!?

  1. #1
    Join Date
    Jan 2012

    Javascript not working in Internet Explorer!?

    Hi everyone.

    Sorry - also posted this on HTML forum by mistake.

    Fairly new to html. Any ideas why this little bit of code doesn't work in IE but fine on Chrome:

    <script type="text/javascript">
    var reimg
    window.onload=function () {
    setInterval(function () {
    reimg.src=reimg.src.replace(/\?.*/,function () {
    return '?'+new Date()

    <img src="" id="re" width="" height="">

    Any help would be very much appreciated!

  2. #2
    Join Date
    Oct 2010
    Versailles, France
    I suppose it's run with a src, a width or a height ? What do you exactly want to do ?
    It seems curious to want to reload the same image, if any with a query sign after the suffix(*), all the 5 milliseconds, which is a very short delay ?

    The replace, with a callback function replace, a myImage.jpg?(...) with a myImage.jpg?Thue jan 24 2012 15:15:15 GMT+0100 which is a not valid address a new Date().getTime() or new Date().valueOf() could be better to reload effectively the image ?

  3. #3
    Join Date
    Jan 2012
    Well, I'm trying to change an image on a page without totally refreshing the entire page and so the user looking at the webpage doesn't have to do anything.

    So I'm FTing anew image but with the same file name to the server, so that it replaces itself with an updated image - if you see what I mean.

    Since the image change can happen at any time, I need to keep the delay short so it is constantly able to change.

    Thanks for your suggestion - but I don't quite follow. Would you be able to change what I already have so I can see?

    Thanks you so much for your help.

  4. #4
    Join Date
    Oct 2010
    Versailles, France
    Try this code with a valid image src followed-up of a question mark (*)...
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="fr">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="generator" content="PSPad editor, www.pspad.com">
    <style type="text/css">
    <script type="text/javascript">
    var srcImg;
    	setInterval(function(){srcImg=srcImg.replace(/(\?).*/,function(){return arguments[1]+new Date().getTime()})},1000);
    <img id="tagImg" src="theImageName.jpg?">
    Add, if necessary, an unique dimension of the image (the width or height to preserve the proportions). It probably not possible to decrease the delay (1000 milliseconds or one second now) to build a cartoons : more than 16 images per seconds and a delay less than 67 milliseconds

    (*) This question mark followed by a variable number force the reload of the image which seems different of the previous one.

    See to this tread to catch the date of an image
    Last edited by 007Julien; 01-24-2012 at 02:48 PM.

  5. #5
    Join Date
    Apr 2011
    I'm using basically the same code as you posted (with a much longer refresh rate) to display webcam images and it works fine for me in all browsers, except that in IE and Chrome only part of the image is displayed. The original image is larger than the iframe that I display it in but in Firefox it reduces to fit, which is great. Any idea why only part of the image displays in IE and Chrome?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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