You can use window.postMessage for this purpose if you have control over the documents in both locations. This allows you to pass messages between documents and across domains, and also provides some level of security. For example, in this scenario, when you need to get the scrollTop value from the parent window, you could send it a message:
parentWindow.postMessage('scrollTop', targetOrigin, [...]);
The parent window would have a listener for the message that could respond with the information:
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) {
var response = null;
if (event.origin !== "http://example.org:8080") {
return;
}
if (event.data === 'scrollTop') {
response = $(document).scrollTop();
childWindow.postMessage(response, targetOrigin, [...]);
return response;
}
return false;
}
The child window would also have a listener:
window.addEventListener("message", receiveMessage, false);
The receiveMessage function would then use the received information.
If you wanted a more general purpose solution, your parent Window's receiveMessage function could simply respond with the result of the following:
response = $(document)[message]();
where message would contain whatever jQuery call you were interested in receiving. Further abstractions could be made, of course.