Javascript problem

Discussion in 'JavaScript' started by Ben H, May 15, 2007.

  1. #1
    I have a function which displays a gif until an rrs feed loads up.

    Is there a way so say:

    If the gif has been displayed for more than 30 seconds, do something like a popup on the screen?
     
    Ben H, May 15, 2007 IP
  2. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #2
    Yes start a timer after rss feeds is loaded up, in the timeout function put a pop up.
     
    it career, May 15, 2007 IP
  3. Ben H

    Ben H Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    im a total newb at javascript by the way :(

    could anyone put in a little piece of sample code?
     
    Ben H, May 15, 2007 IP
  4. Ben H

    Ben H Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Here is a function I put together...

    	var x = 0;
    	var y = 1;
    	function timingex(){
    		x = x+y;
    		var timer = setTimeout("timingex()", 1000);
    		//document.RssForm.But.value = x
    		if(x==10){ 
    			document.getElementById("result").innerHTML = '<br><center><img src="_graphics/404-logoA.jpg" alt="Error"></center><p>TNN RSS feed could not be loaded</p>';
    			document.getElementById("visibilityPrev").style.visibility = "hidden";
    			document.getElementById("visibilityNext").style.visibility = "hidden";
    			clearTimeout(timer);
    		}
    	}
    Code (markup):
    However this runs as soon as the page has been open 10 seconds. I have another function:

    	function loading(){
    		document.getElementById("result").innerHTML = '<br><br><center><img src="_graphics/loading.gif" alt="Loading..."></center>';
    	}
    Code (markup):
    This opens up an image while the RSS feed is being loaded. Ideally, I want to be able to see if the image in the loading() function had been on the screen for more than a certain amount of time then run the timingex() function. How would I go about doing this?
     
    Ben H, May 15, 2007 IP