Getting the previous and next page Id.

Getting the previous and next page Id.

Hi, how can I go about grabbing the previous page id (if there is one) and the id of the page it is transitioning to.

Also, how can I remove a page from the history stack? For example if I have three pages:

Page 1 > Page 2 > Page 3. How cand I remove Page 2 from history so that adding a back button to the header on a Page 3 reverts back to Page 1 instead of Page 2.

Thanks in advance.