Rize S. answered 03/23/23
Senior IT Certified Trainer, IT Developer & DBA Administrator
No, app.activeDocument.currentPage returns the active page of the document, not the page where the cursor is. To get the page where the cursor is, you can use the TextFrame.parentPage property. Here's an example:
var currentPage = app.selection[0].parentTextFrames[0].parentPage;
alert("Current page number: " + currentPage.documentOffset);
This code assumes that there is at least one item selected in the document, and that it is a text frame. It gets the parent text frame of the first selected item, and then gets the parent page of the text frame. The documentOffset property returns the index of the page within the document, so it can be used as the current page number.