Jump to content

Reload/refresh of a site


Guest Lars

Recommended Posts

Guest Lars

I'm working on my guestbook. Everything works except form one thing. When someone wants to put a message in my guestbook I open a new window where I have the form and where I validate the input. If I validate the input I submit the input to a php.file where I put the message into a database. Now I wants to refresh the main page form where I came before I close the window with a window.close command.How do I do that?Does anyone have a solution?best regardsLars

Link to comment
Share on other sites

I think there is a javascript thing to do this.. Like a timeout() function. w8 ill look it up, I have a file floating around here somewhere.*edit* oops, thats to call a function every "X" milliseconds. I think you could use ajax for this.. just make a page that displays the chat, then do an AJAX call to it and have a div where ever the chat is then do this:

function setTimers(){// the 1000 is how often to do the function in milliseconds, 1 second = 1000 //milliseconds. 2 or 3 seconds is reccomended so server isnt flooded.timeout = window.setTimeout( "getchat()", 2000 );}function getchat(){*ajax code here, dont want to write lol*//gets state of requestxmlhttp.onreadystatechange = //if state equals 4, which is ready, and status, which is if page is accessible or not it does //codeif( xmlhttp.readyState == 4 && xmlhttp.status == 200 ) {chatbox.innerHTML = xmlhttp.responseText;}else{alert("There has been an error with the chat code! Sorry about this trouble.");}}

now, go look up the rest of the code for the ajax and getting the chat lol. on the page anywhere include that file or just put it in there and in a javascript <script> tag start the setTimers(); function... thats it!

Link to comment
Share on other sites

Now I wants to refresh the main page form where I came before I close the window with a window.close command.How do I do that?
Use the code below, this will reload() the window that opened it, thus refreshing your page with the updated data :)
window.opener.location.reload();window.close();

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...