Forum Moderators: open
window.openerproperty to pass commands to the parent window.
How do you let the user select data in the popup?
As for showing it in a <div>: address the div via its ID, and change the value of the div's
innerHTMLproperty.
This comes in two parts.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- doctype all on one line -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Window.Opener Test</title>
<script type="text/javascript">
function newWindow () {
var day = new Date();
var id = day.getTime();
var params='width=600,height=600,scrollbars,resizable';
var win = open('popwin.html',id,params);
}
</script>
</head>
<body>
<h1>Window.Opener Test</h1>
<p><a href="#" onClick="return newWindow();">Open editor</a></p>
<p id="write_me"></p>
</body>
</html>
Contents of file "popwin.html:"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- doctype all on one line -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Window.Opener Part Two</title>
<script type="text/javascript">
function populate () {
if (document.getElementById) {
var txt = document.getElementById('txt').value;
var target = window.opener.document.getElementById('write_me');
target.innerHTML=txt;
window.close();
return false;
}
}
</script>
</head>
<body>
<h1>Window.Opener Part Two</h1>
<form action="" onSubmit="return populate();">
<textarea name="txt" id="txt" rows="6" cols="25">Enter some text here</textarea>
<input type="submit" value="Populate Parent and Close">
</form>
</body>
</html>