We help IT Professionals succeed at work.

jQuery reload entire page after Confirm alert is clicked

Robert Granlund
Last Modified: 2018-11-01
jQuery.  Is there a way to reload an entire page, after a confirmation alert is clicked?
Watch Question

Consultant & Challenge Subduer
Top Expert 2009
This one is on us!
(Get your first solution completely free - no credit card required)
One of the solutions is location.reload(), as David mentioned. This will refresh your page and stay at the scrolled position. If this is what you want, go with it.

If you want to refresh the page and go to the top, use "location.href = location.href" instead; this will reload and go to the top which is sometimes useful when the page content changes a lot due to user action. Side effect: this will use a GET request even when the original page has been shown by a POST. Also useful to avoid the confirmation nagging in some postback situations.

Also, you can give location.reload() an argument (true/1/something) to make sure it fetches every resource - this is the equivalent of Ctrl-F5. Use this when the user action involves "heavy" items that are usually cached, typically images.

Finally, you can make "indoor reloads" with jQuery which allows you to only replace a dom element with the fetched fresh contents. See $.load() on this.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.