Can you use page in title rather than trying to calculate it fresh? This would require that learners move forward and do not have a Table of Contents or Menu where they can jump ahead. You could save the largest page number attained. You may need to adjust for pages in your popup area.