简体   繁体   中英

Reload previous visited page in javascript

I have a web page whithin i have display an image, when someone clicked on the image, The image is poped-in. And then, there is a close button after viewing the photo.

Now, I would like to add the the event onclick one function that allow me to refresh/reload the page. So I will have this sequence ( close popin ==> back to the page ==> reload the page)

Am not good in JS, i would like to do it in javascript.

To reload the current page, you can use:

location.reload(true);

To reload the previous page, you can try:

history.go(-1);

There are several ways you can do this, look here for more info.

A call to window.location.reload() will do the job.

If you want to completely reload the page (ie resending any POST requests that may have occurred), use location.reload() . If you do this on a POST request, the browser will ask you if you want to submit the data again (if you use this technique).

If you want to avoid resending a POST request but just GET the resource this time round, use location.href = location.href .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM