www.webdeveloper.com
+ Reply to Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Nov 2012
    Posts
    3

    Post Auto Refresh an Image only

    Hi All,

    I am a newbie in webprogramming, but need to use an autorefresh image script. At the moment I am using this code_

    <head>
    <style type="text/css">
    .style1 {
    text-align: center;
    }
    </style>
    </head>
    <hr>
    <body style="color: #FFFFFF; background-color: #F3F3F3">
    <div class="style1">
    <IMG src="IMAGE URL HERE" border="1" name="refresh">
    <SCRIPT language="JavaScript" type="text/javascript">
    var t = 20 // Interval in Seconds
    image = "IMAGE URL HERE" //URL of the Image
    function Start() {
    tmp = new Date();
    tmp = "?"+tmp.getTime()
    document.images["refresh"].src = image+tmp
    setTimeout("Start()", t*1000)
    }
    Start();
    </SCRIPT> </div>

    ________________________________________________________________

    <iframe src="autorefresh.html" name="frm-content" frameborder="0" marginheight="0" marginwidth="1" scrolling="no" width="100%" style="border-style: solid; border-width: 0px" align="center" height="220" />
    </iframe>


    This is working fine for one image, but how can I apply this script to multiple images on the same page?? I need to auto refresh 10 images.. Any help will be highly appreciated.

  2. #2
    Join Date
    Mar 2009
    Posts
    452
    <IMG src="IMAGE URL HERE" border="1" name="refresh" id="img1">
    <IMG src="IMAGE URL HERE" border="1" name="refresh" id="img2">
    <IMG src="IMAGE URL HERE" border="1" name="refresh" id="img3">

    <SCRIPT language="JavaScript" type="text/javascript">
    var t = 20 // Interval in Seconds
    images = new Array('1.jpg','2.jpg','3.jpg'); //URLs of the Images

    function Start() {
    tmp = new Date();
    tmp = "?"+tmp.getTime();
    for (i=1;i<image.length;i++){
    document.getElementById("img"+i).src = images[i]+tmp;
    }
    setTimeout("Start()", t*1000)
    }
    Start();
    </SCRIPT>

  3. #3
    Join Date
    Nov 2012
    Posts
    3

    Wink

    Thanks ZABI for your reply and for your help.. I have applied the code in this case;

    <IMG src="imgcam/mostasquare_1.jpg" border="1" name="refresh" id="img1">
    <IMG src="imgcam/mriehelbypass_1.jpg" border="1" name="refresh" id="img2">

    <SCRIPT language="JavaScript" type="text/javascript">
    var t = 35 // Interval in Seconds
    images = new Array('../imgcam/mostasquare_1.jpg','../imgcam/mriehelbypass_1.jpg'); //URLs of the Images

    function Start() {
    tmp = new Date();
    tmp = "?"+tmp.getTime();
    for (i=1;i<image.length;i++){
    document.getElementById("img"+i).src = images[i]+tmp;
    }
    setTimeout("Start()", t*1000)
    }
    Start();
    </SCRIPT>

    ________________________________________________________________

    <iframe id="img1" src="autorefresh.html" name="img1" frameborder="0" marginheight="0" marginwidth="1" scrolling="no" width="460" height="345" /></iframe>

    <iframe id="img2" src="autorefresh.html" name="img2" frameborder="0" marginheight="0" marginwidth="1" scrolling="no" width="460" height="345" /></iframe>


    I am seeing the same image for both iFrames.. Sorry for this but I have no knowlede in programming.. Many thanks for your time and help

  4. #4
    Join Date
    Mar 2009
    Posts
    452
    what basically you want to achieve ?

    what are those iframes for ? as far as your question i understood your question that you want to refresh images. you just need only img elements not iframes.

Thread Information

Users Browsing this Thread

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

     

Bookmarks

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



Recent Articles