lional Posted November 1, 2012 Share Posted November 1, 2012 Hi I have two iframe ad banners on a page. I want each one to refresh every 8 seconds. One is on the far left and the other on the far right. I can only get one to refresh. Here is my code <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="js/featuredcontentglider.js">/************************************************ Featured Content Glider script- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts* This notice must stay intact for legal use***********************************************/</script> <!--- Right hand iFrame ---> <script type="text/javascript"><!-- // set your interval in milliseconds var reloadInterval = 8000; // this will run when the document is fully loaded function init() { setTimeout('reload()',reloadInterval); } // this reloads the iframe, and triggers the next reload interval function reload() { var iframe = document.getElementById('reloader_lft', 'rht_reloader'); if (!iframe) return false; iframe.src = iframe.src; setTimeout('reload()',reloadInterval); } // load the init() function when the page is fully loaded window.onload = init; --></script> <div id="banner_left"> <iframe src="banner_left.php" width="200" height="485" scrolling="no" id="reloader_lft" style="border:0px;padding:0px;margin-top:-6px"></iframe> </div> <div id="banner_right"> <iframe src="banner_left.php" width="200" height="485" scrolling="no" id="rht_reloader" style="border:0px;padding:0px;margin-top:-6px"></iframe> </div> Thanks Lional Quote Link to comment https://forums.phpfreaks.com/topic/270148-auto-refresh-twoif-rames-on-a-page/ Share on other sites More sharing options...
codefossa Posted November 1, 2012 Share Posted November 1, 2012 If you give them both the same class, you could do something like this. I'm assuming you want them to alternate reloading every 8 seconds, since you said load one. If you wanted to load both, just go through the class you set with a for loop and refresh them all. var first = true; setInterval(function() { var n = first ? 0 : 1; window.document.getElementsByClassName("myClass")[n].contentwindow.location.reload(); first = !first; }, 8000); Quote Link to comment https://forums.phpfreaks.com/topic/270148-auto-refresh-twoif-rames-on-a-page/#findComment-1389254 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.