Javascript : History Back() Method
Solution 1:
No, it isn't.
That page isn't part of the current window's history.
That is why the browser's back button wouldn't work either.
Solution 2:
You can send the url(window.location.href
) to the new tab and in the new tab use the history
api to push the url to the history state. Look here: Working with the History API
Solution 3:
Edit: Misundersood your question.
So, if you want to create this on you own, it is possible to give the url you are opening in the new tab an attribute with the referrer url. Something like this:
http://yourpage.com/?referrer=http%3A%2F%2Fyourpage.com%252Fsublink
Otherwise there is no possiblity for what you want to achieve.
THIS IS NOT THE SOLUTION, JUST DOESN'T WANT TO WASTE IT
It actually is possible. Just take a look at the document object, and you will find a referrer attribute. It's the URL you are coming from.
If you want to open a new tab you should take the workaround from duke that looks like this:
functionOpenInNewTab(url) {
var win = window.open(url, '_blank');
win.focus();
}
After this, you can create a new link with an onclick
attribute:
<a onclick="OpenInNewTab(document.referrer);">Openlastinnew tab</a>
Post a Comment for "Javascript : History Back() Method"