Solved

refresh item on page(iframe, table, or div)

Posted on 2006-06-08
1
515 Views
Last Modified: 2008-02-01
I would like to refresh an iframe on my website at a given interval. I have some code below. It is not working when I use the url in the src.  However, if I replace the iframe src with an image file vs a url, it works fine. Any one  know why?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
    <SCRIPT LANGUAGE="JavaScript">
<!--

var secs
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 25
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        self.status = ""
        // Here's where you put something useful that's
        // supposed to happen after the alotted time.
        // For example, you could display a message:
       
        refresh();
        InitializeTimer();
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}

//-->
</SCRIPT>
</head>
<body onload="InitializeTimer()">
<table BORDER=0 CELLSPACING=0 CELLPADDING=0 bordercolor="#111111" >
<tr><td WIDTH="100%">
<iframe id="ifx" width="365" scrolling="No" height="340" frameborder="no" src="http://pub.camera.trafficland.com/trafficimage.php?system=ladotd&webid=2039&pubtoken=7294826e9eb4e70cbd3c86630f4186b7&0.44067952619013856"></iframe>
</td>
</tr>
</table>

<form>
  <p><input type="button" onclick="refresh()" value="Refresh Form Button"
  name="button1"></p>
</form>


<script language="JavaScript">
function refresh()
{
      document.ifx.location.reload();
}
</script>
</body>
</html>
0
Comment
Question by:LeeHenry
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 16866189
Here my version:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Zvonko &#42;</title>
    <SCRIPT LANGUAGE="JavaScript">
<!--

var secs
var timerID = null
var timerRunning = false
var delay = 1000
var camera = "http://pub.camera.trafficland.com/trafficimage.php?system=ladotd&webid=2039&pubtoken=7294826e9eb4e70cbd3c86630f4186b7&0.44067952619013856";
function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 25
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        self.status = ""
        // Here's where you put something useful that's
        // supposed to happen after the alotted time.
        // For example, you could display a message:
       
        refresh();
        InitializeTimer();
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}

//-->
</SCRIPT>
</head>
<body onload="InitializeTimer()">
<table BORDER=0 CELLSPACING=0 CELLPADDING=0 bordercolor="#111111" >
<tr><td WIDTH="100%">
<iframe name="ifx" id="ifx" width="365" scrolling="No" height="340" frameborder="no" ></iframe>
</td>
</tr>
</table>

<form>
  <p><input type="button" onclick="refresh()" value="Refresh Form Button"
  name="button1"></p>
</form>


<script language="JavaScript">
function refresh(){
  window.frames.ifx.location=camera+"&time="+(new Date()).getTime();
}

refresh();
</script>
</body>
</html>


0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question