Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

History.Back with refresh

I would like to have the History.back(); functionality with a complete refresh of previous page.

Any idea how to do that (and make it work in IE, FF and Chrome).

like image 941
Larsi Avatar asked Jan 11 '11 12:01

Larsi


People also ask

Does history back refresh page?

The History function is another method for refreshing a page. The history function is used as usual to navigate back or forward by passing in either a positive or negative value.

What is history back ()?

The History. back() method causes the browser to move back one page in the session history. It has the same effect as calling history.go(-1) . If there is no previous page, this method call does nothing.

What is the syntax and use of history back method?

HTML | DOM History back() Method The History back() method in HTML is used to load the previous URL in the history list. It has the same practical application as the back button in our web browsers. This method will not work if the previous page does not exist. This method does not contain any parameter.

How do I go back to previous page in Javascript?

The history. back() method loads the previous URL (page) in the history list. The history. back() method only works if a previous page exists.


2 Answers

You could redirect (by window.location) to document.referrer

i.e.

window.location.href = document.referrer;

Internet Explorer fix for passing referrer to a particular location:

if(IE){ //IE, bool var, has to be defined
    var newlocation = document.createElement('a');
    newlocation.href = URLtoCall;
    document.body.appendChild(newlocation);
    newlocation.click();
}
like image 96
stecb Avatar answered Oct 17 '22 09:10

stecb


You can also use the location replace() method:

window.location.replace(document.referrer)
like image 41
Mori Avatar answered Oct 17 '22 10:10

Mori