In the example below, the variable pageNum will contain the number of the current page open in the publication.
var pageNum = GetPageNumber()