Yes that works way better. No worry about Chapters and Sections. You just have to ensure a variable for LastPageId is updated on every page… and publish with this option checked: Convert Page Names to short ID-based Names
And then with this function you can go back to your last stored page..
lastPageId = VarLastPageId.getValue();
var test = “page”+lastPageId+”.html”;
Make sure your summary pages dont inherit any code storing the IDs and all will work fine.