One more step towards technology

Update a parent window from a child – Java Script

In Fun with technology on July 9, 2010 at 7:42 am

Parent Window HTML

<!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>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>
<script language=”javascript”>
function parent_call()
{
alert(“I am your parent”);
}

function openme()
{
window.open (“file2.html”,”mywindow”,’height=200, width=200, resizable=no, scrollbars=no,toolbar=no,location=yes, directories=no, status=no, menubar=no, copyhistory=yes’);
}
</script>
</head>

<body>
<input type=”text” id=”parent_text” />
<input type=”button” value=”Open Child Window” onclick=”openme()” />
</body>
</html>

Child Window HTML

<!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>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>
<script language=”Javascript” type=”text/javascript”>

function updateParent_text()
{
window.opener.document.getElementById(“parent_text”).value = document.getElementById(“TextBox1″).value;
//return false;
}

function call_parent()
{
window.opener.parent_call();
//return false;
}
</script>
</head>

<body>
<input type=”text” id=”TextBox1″ />
<input type=”button” value=”Update Parent Text” onclick=”updateParent_text()” />
<input type=”button” value=”Call Parent Window” onclick=”call_parent()” />

</body>
</html>

Advertisement
  1. Good Going Dear, I like your all posts

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.