how to access document from a pop up

S

soup_or_power

Hi
I want to set the main document variables from a pop-up.

The code will be somewhat like this (sorry for mistakes) but it isn't
setting the main document's input box value. Please help!

<html>
<head>
<script language="javascript">
function mypopup() {
var win=window.open(...);
var message="<input type=text name=s1 value=yes
onclick=\"document.forms[0].myinput.value='value from popup'\">";
win.document.write(message);
}
</script>
</head>
<form method=post action="myaction.html">
<input type=text name=myinput value='default value' onclick="popup()">
</form>
</body>
</html>
 
V

VK

(1) in your pop-up:
....
self.opener.myFunction(var1, var2, var3);
....

(2) in the main window:
....
myFunction(v1, v2, v3) {
myVar1 = v1;
myVar2 = v2;
myVar3 = v3;
}
....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,689
Members
48,796
Latest member
Greg L.

Latest Threads

Top