Crash course here -- this question has been asked a few times in the last couple of days, so I worked up this very simple example that I think lays the groundwork for what could be turned into something much more complicated if you're so inclined.
The question is, "Can two browser windows communicate between each other?"
The answer is yes, and here's how:
If you have a parent-child relationship between the two browsers, it's fairly simple. Here's an example:
thePage.htm:
<html>
<head>
<title>Test</title>
<script language="javascript">
function openMe(){
var x = window.open('newOne.htm', 'newWindow', 'height=300,width=300');
}
</script>
</head>
<body>
<form name=theForm>
<INPUT type=button value="Open It" name=submit1 onClick="openMe();">
<input type=text name=theBox>
</form>
</body>
</html>
newOne.htm:
<html>
<head>
<title>testing</title>
<script language=javascript>
function setOther(){
window.opener.theForm.theBox.value = document.myForm.thisBox.value;
}
</script>
</head>
<body>
<form name=myForm>
<input type=text name=thisBox>
<input type=button value="Click Me" onClick="setOther();">
</form>
</body>
</html>
Now all that does is when you click the button, it opens up the new page in a pop up window, and when you type something in the text box in the pop up, and push that button, it assigns that value back to the text box on the original page. From this example, though, it's easy to see how to communicate between the two windows.
Happy Coding Everyone!
