Solved

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

Posted on 2006-06-08
1
514 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
[form-control] Retain values after a POST action 21 66
Check input text, Number 7 51
How do i use the await event in php echo 5 35
Conformation code 4 31
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

740 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