How do I refresh a page using JavaScript?

javascript, jquery, refresh, reload

Solution

Use `location.reload()`.

For example, to reload whenever an element with `id="something"` is clicked:

$('#something').click(function() {
    location.reload();
});

The `reload()` function takes an optional parameter that can be set to `true` to force a reload from the server rather than the cache. The parameter defaults to `false`, so by default the page may reload from the browser's cache.

Problem

How do I refresh a page using JavaScript?

Original source

Related problems