matfish Posted April 3, 2007 Share Posted April 3, 2007 Hi, Iv got a simple standard page (html) with a few iframes which pulls in different stats (its a work related thing). I want to update one of the iframes only. Putting a meta refresh within that one iframe still reloads the whole page. Im new to Ajax, anyone know of how to refresh one 1 iframe on a timer? Many thanks Link to comment https://forums.phpfreaks.com/topic/45419-refresh-individual-iframes/ Share on other sites More sharing options...
ober Posted April 3, 2007 Share Posted April 3, 2007 Refreshing with AJAX pretty much removes the need for the iframe. Either way, all you need to do is use a javascript timer to call a refresh javascript function. In your response function, simply restart the timer. Play with the example here: http://www.phpfreaks.com/forums/index.php/topic,115581.0.html Then once you've written some of the code yourself, ask again. Link to comment https://forums.phpfreaks.com/topic/45419-refresh-individual-iframes/#findComment-220529 Share on other sites More sharing options...
jitesh Posted April 4, 2007 Share Posted April 4, 2007 From one frame you can target another frame <iframe name="a" src="displayimage.php?imageid=1"> <iframe name="b" src="listofimages.php"> in file listofimages.php suppose you have a link <a href="displayimage.php?imageid=<?php echo $imageid?>" target="a"> Link to comment https://forums.phpfreaks.com/topic/45419-refresh-individual-iframes/#findComment-221006 Share on other sites More sharing options...
matfish Posted April 4, 2007 Author Share Posted April 4, 2007 Thank you both. I thought this would be an Ajax thing but javascript seemed to handle it: <html> <head> <script type="text/javascript"> //Example to show 2 iframes, which the google iframe is being refreshed on its own var reloadInterval = 3000; function init() { setTimeout('reload()',reloadInterval); } function reload() { var iframe = document.getElementById('window1'); if (!iframe) return false; iframe.src = iframe.src; setTimeout('reload()',reloadInterval); } window.onload = init; </script> </head> <body> <iframe id="window1" width="500" height="400" src="http://www.google.com/"/></iframe> <iframe id="window2" width="500" height="400" src="http://www.yahoo.com/"/></iframe> </body> </html> Link to comment https://forums.phpfreaks.com/topic/45419-refresh-individual-iframes/#findComment-221058 Share on other sites More sharing options...
mainewoods Posted April 5, 2007 Share Posted April 5, 2007 iframe.src = iframe.src; Done that before, and one thing I can tell you is that if the user uses the backpage afterwards, the results will be very ugly! The backpage will load the iframe src as the whole page. Definitely very confusing for the user. Link to comment https://forums.phpfreaks.com/topic/45419-refresh-individual-iframes/#findComment-221785 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.