How to reload a page using JavaScript

前端 未结 19 2925
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 00:46

How can I reload the page using JavaScript?

I need a method that works in all browsers.

19条回答
  •  眼角桃花
    2020-11-22 01:44

    I was looking for some information regarding reloads on pages retrieved with POST requests, such as after submitting a method="post" form.

    To reload the page keeping the POST data, use:

    window.location.reload();

    To reload the page discarding the POST data (perform a GET request), use:

    window.location.href = window.location.href;

    Hopefully this can help others looking for the same information.

提交回复
热议问题