Is it possible to go back to specified page id in jQuery mobile?

Is it possible to go back to specified page id in jQuery mobile?

Suppose I have 4 pages with this page IDs:

pageA -> pageB -> pageC -> pageD

There can be an event in pageC and pageD that can make the application go back to pageB, the problem is that depending on the page I'm currently at I should call history.go(-N) where N is the number of pages that I should go back. For example if I am in pageD I should call history.go(-2), in case of pageC history.go(-1) to keep history consistently. How would you do that in jQuery Mobile so that history would contain:

pageA -> pageB

Another solution would be just to navigate to pageB directly with $("body").pagecontainer("change", "pageB.html") the problem with that is that the history chain would be wrong like this:

pageA -> pageB -> pageC -> pageD -> pageB

All pages have a back button that's why it is important to keep history chain consistently.

---
Alfredo Osorio