This is how you would do it. Passing function arguments is tricky when the function isn't on the same page as the calling statement because of the way functions and variables work in relation to the window object, but its not impossible. I show a very simply way of doing this, but you can certinaly expand it.
test.html:
<html>
<head>
<script LANGUAGE="JavaScript" TYPE="text/javascript">
function openWindow(){
WREF = window.open("test2.html","test2",'width=550,height=650');
if(!WREF.opener){ WREF.opener = this.window; }
}
function getValue(val){
newVal = 5 * val;
return newVal;
}
var globalGetValue = this.getValue;
</script>
</head>
<body>
<a HREF="javascript:void(0);" onClick="openWindow();">Open the window</a>
</body>
</html>
test2.html:
<html>
<head>
</head>
<body>
<script LANGUAGE="JavaScript" TYPE="text/javascript">
document.write("This is 5 x 7: " + opener.globalGetValue(7));
</script>
</body>
</html>
Just be careful not to call the function BEFORE the window is fully loaded, perhaps by using a callback logic that forces your parent script to wait until the child window executes and alters a variable.
var callbackvar = false;
var sleepcount = 0;
while(!callbackvar){
sleepcount++;
}
then in your child, you'll have, as the last thing that happens when the page loads, something that does opener.callbackvar = true;
Then, the parent can communicate with a fully loaded child window. You'll need to test and tweek this... I'm writing off the cuff without testing anything... This while loop will run away if you're not careful... for testing, put a more defined end-state in like:
var callbackvar = false;
var sleepcount = 0;
while(!callbackvar || sleepcount > 100000){
sleepcount++;
}