efficacious Posted June 18, 2011 Share Posted June 18, 2011 Hi all, I've written a chat box via php/mysql and my only real issue with it is that I cannot get it to refresh the chat display properly. I tried adding a meta refresh to the display page that loads into the Iframe but FF has a bug in which it fails to recognize the new location of the Anchor so it screws up the autoscroll for the chat messages.. So in order to try and fix that issue I decided I should just write up a delayed javascript function to refresh the display. Here is my javascript so far: function RefreshChat() { var Display = document.getElementById('Display'); if(Display != null) { Display.src = "Chat.php&VarName=Value#Anchor"; } } The HTML bit: <iframe onload='setTimeout("RefreshChat()",9000);' src='Chat.php&VarName=Value#Anchor' name='Display' id='Display'></iframe> thats all the code except for the chat.php page..but all that page does is takes the values in and outputs the messages it does also contain the Anchor <div id='Anchor' name='Anchor'></div> Can any1 tell me why the function doesn't seem to want to fire more than one time? Even though after the first time it fires the iframe is loaded again? What it feels like to me is that the browsers keep breaking my loop Quote Link to comment https://forums.phpfreaks.com/topic/239733-looping-iframe-reload-need-help/ Share on other sites More sharing options...
fugix Posted June 18, 2011 Share Posted June 18, 2011 You could set a recursive function to consistently call the function every x amount of seconds Quote Link to comment https://forums.phpfreaks.com/topic/239733-looping-iframe-reload-need-help/#findComment-1231511 Share on other sites More sharing options...
efficacious Posted June 18, 2011 Author Share Posted June 18, 2011 could you show me an example of that? Quote Link to comment https://forums.phpfreaks.com/topic/239733-looping-iframe-reload-need-help/#findComment-1231570 Share on other sites More sharing options...
fugix Posted June 18, 2011 Share Posted June 18, 2011 Something like function RefreshChat() { var Display = document.getElementById('Display'); if(Display != null) { Display.src = "Chat.php&VarName=Value#Anchor"; } setTimeout("RefreshChat()", 9000); } Quote Link to comment https://forums.phpfreaks.com/topic/239733-looping-iframe-reload-need-help/#findComment-1231580 Share on other sites More sharing options...
efficacious Posted June 18, 2011 Author Share Posted June 18, 2011 ah ok duh that makes sense.. thanks i'll give that a shot. Quote Link to comment https://forums.phpfreaks.com/topic/239733-looping-iframe-reload-need-help/#findComment-1231582 Share on other sites More sharing options...
efficacious Posted June 19, 2011 Author Share Posted June 19, 2011 i tried adding that recursive bit to the function but each browser still breaks it after 1-2 fires. I think i may just have to take this to a different format that gives more control over the display Quote Link to comment https://forums.phpfreaks.com/topic/239733-looping-iframe-reload-need-help/#findComment-1231826 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.