chrischen Posted February 21, 2008 Share Posted February 21, 2008 I have ajax load an external page into a div. How do I unload that to return the page to the normal state like it is if the person refreshes it? Quote Link to comment Share on other sites More sharing options...
phpQv3.0 Posted February 21, 2008 Share Posted February 21, 2008 You could do something like this: <script language="javascript"> var content = "yourDIVsIDHere"; // replace this with your div's id; the div that contains your external page, that was loaded by ajax function resetDIV() { document.getElementById(content).innerHTML; } </script> <div id="yourDIVsIDHere"> <!-- external page would have been displayed here --> </div> <br><br> <input type="button" onclick="resetDIV()" value="Clear It!"> Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted February 22, 2008 Share Posted February 22, 2008 or... instead of replacing the old text you could just use a style to hide it. and display the new, then vise versa to go back. so... /* Some ajax stuff above */ if(ajaxRequest.readyState == 4){ document.getElementById('newPageStuff').style.display = "block"; document.getElementById('oldPageStuff').style.display = "none"; } /* Some ajax stuff below */ Quote Link to comment 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.