Getting the id of a page when leaving it.

Getting the id of a page when leaving it.

How can I get the page id of when it is transitioned away from.

For example if I transition from page 1 to page 2 on leaving page 1 I grab the page id attribute of page 1?

I have tried pagehide and pagebeforehide but I seem to get the id of the second page in this case page 2.

Thanks in advance.