There's no way for the parser to know about the fields you're referring to from another page.
What you could do is to either send the ID:s along with the function that opens the new window.
Depending on your situation:
If the new page also is an XPage: as a Requestscope variable.
Or in the URL and then extract them from there, or place the ID:s in a cookie or not open a new window at all! Open a Dojo dialog instead, then you'll have access to the same fields. And you javascript would work.
If you MUST have a new window and that same window isn't an XPage, you could call a function on the originating page that returned the proper ID:s that you're after. That function will have access to the proper ID:s, since that JavaScript will be parsed for SSJS and know about the fields you're trying to get at.
/J