The current page:
var page = app.activeWindow.activePage;
-- this is the page that is active & visible on your screen (not the one selected in the Pages panel! -- I think I told someone else that a while ago).
If there are parts of more than one page visible, ID seems to select one by some fixed rule ('biggest part visible', 'first one when seen left to right', 'the top one if it shows more than half of it' -- something like that).
(Post-Edit) Oh and this property has nothing to do with the current selection. I guess it depends on what you want to do next.
Another way getting that done is based upon what is your current
if (theObj.constructor.name == "Page") return theObj;
if (theObj.constructor.name == "Character" || theObj.constructor.name ==
if (theObj.constructor.name == "Application")
// Frame is on an unexpected place...
alert ("Can't able to find the page");
Once more, thank you for your help.
After trying again and again, I added an alert to try to track the changes, and things started to work. This led me to the conclusion that the content wasn't actually on the page yet. Looking again, I had my importXML command within the main function, so the rules weren't being applied because content hadn't actually been placed on the page yet. I still find it odd that all my other rules were working, but it seems that if the content is already on the page, then this rule works too. Odd, but seemingly what's happening.