JavaScript Window History
- Previous Page JS Location
- Next Page JS Navigator
Ang object na window.history ay naglalaman ng kasaysayan ng browser.
Window History
window.history
Ang object ay pwedeng magkaroon ng walang window sa pagpaliwanag.
Para protektahan ang privacy ng user, may limitasyon ang pag-access ng JavaScript sa object na ito.
Ilang paraan:
- history.back() - Katumbas ng pag-click sa pindutin na magpunta sa nakaraang pahina sa browser
- history.forward() - Katumbas ng pag-click sa pindutin ang pindutin na magpunta sa unang pahina sa browser
Bumalik sa Nakaraang History
history.back()
Method loads the previous URL in the history list.
This is equivalent to clicking the back button in the browser.
Example
Create a back button on the page:
<html> <head> <script> function goBack() { window.history.back() } </script> </head> <body> <input type="button" value="Back" onclick="goBack()"> </body> </html>
The output of the above code will be (click this button):
Window History Forward
history forward()
Method loads the next URL in the history list.
This is equivalent to clicking the forward button in the browser.
Example
Create a forward button on the page:
<html> <head> <script> function goForward() { window.history.forward() } </script> </head> <body> <input type="button" value="Forward" onclick="goForward()"> </body> </html>
The output of the above code will be:
- Previous Page JS Location
- Next Page JS Navigator