Example.
User was in /home.html
redirected to /room.html
press back button in browser(or backspace) -> came back to /home.html
is there a javascript or jquery function to fecth the previous page url?(/room.html)
Example.
User was in /home.html
redirected to /room.html
press back button in browser(or backspace) -> came back to /home.html
is there a javascript or jquery function to fecth the previous page url?(/room.html)
You can use document.referrer to get that.
string url = document.referrer;
Description: Returns the URI of the page that linked to this page.
The value is an empty string if the user navigated to the page directly (not through a link, but, for example, via a bookmark). Since this property returns only a string, it does not give you DOM access to the referring page, Referance.
is there a javascript or jquery function to fecth the previous page url?(/room.html)
window.history.back()
returns you to the previous page
window.history.forward()
goes forward
check out the window.history
object
The back()
method loads the previous URL in the history list.
This is the same as clicking the "Back button" in your browser, or history.go(-1)
window.history.back()