My aspx page:-
Declare your function like this inside the document ready:
$(document).ready(function() {
window.showMessage = function() {
//...
};
});
Then you should be able to call it from the other document like this:
window.opener.showMessage();
And because it's in the global scope, you can call it from within the main document just by calling
showMessage();