Java Reference
In-Depth Information
if (typeof (newWindow) == “undefined” || newWindow.closed == true)
{
alert(“No window is open”);
}
else
{
document.form1.text1.value = newWindow.document.form1.text1.value;
}
}
function window_onunload()
{
if (typeof (newWindow) != “undefined” && newWindow.closed == false)
{
newWindow.close();
}
}
</script>
</head>
<body onunload=”window_onunload()”>
<form name=”form1” action=”“>
<input type=”button” value=”Open newWindow” name=”btnOpenWin”
onclick=”btnOpenWin_onclick()” />
<p>
newWindow's Text:<br />
<input type=”text” name=”text1” />
<input type=”button” value=”Get Text” name=”btnGetText”
onclick=”btnGetText_onclick()” />
</p>
</form>
</body>
</html>
This is the code for your original window. Save it as ch08_examp5.htm . Now you'll look at the page
that will be loaded by the opener window.
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>Chapter 8: Example 5 Popup</title>
<script type=”text/javascript”>
function btnGetText_onclick()
{
document.form1.text1.value = window.opener.document.form1.text1.value;
}
</script>
</head>
<body>
<form name=”form1” action=”“>
Opener window's text<br />
<input type=”text” name=”text1” />
Search WWH ::




Custom Search