toprashantjha Posted September 17, 2008 Share Posted September 17, 2008 hi all, i am not getting the difference between different page reloading methods.. which are-- 1. history.go(0); 2. document.location.reload(); 3. document.location.replace(document.location); 4. document.location.href='url of page'; Quote Link to comment Share on other sites More sharing options...
Psycho Posted September 17, 2008 Share Posted September 17, 2008 1. history will change the page to one of the URLs in, you guessed it, your history. You can't direct the user to just any url - it has to be one in their history. 2. reload, does just that - reloads the current page 3. replace will direct the browser to the selected URL, but I believe it also replaces the current page with the new page in the browsers history, which is the opposite of #4 4. Location directs the browser to a new URL and ADDs it to the history. Example: user is on page one.htm and then clicks a link to go to page two.htm. Then on page two.htm javascriptuses replace to direct the user to page three.htm. If the user clicks the back button they will go to page one.htm. If documnet.location was used, then the back button would take the user to two.htm Again, not 100% sure on all of this (never had a need to use replace), but a quick search gave me that info. A quick test could verify. Quote Link to comment Share on other sites More sharing options...
toprashantjha Posted September 18, 2008 Author Share Posted September 18, 2008 Thanks, so much. Got some idea... 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.