Window & Data Access

[Total: 0    Average: 0/5]

This shows how to have one window open up another window and monitor that second window for it to have new data and signal that it needs to go away (and have it’s data read).

Body Code:

<form name="ef1">

A = <input name="t1" type="text" value="1">
<input type=button value="Add 1 to A's value" onclick="addToA()"><BR>
B = <input name="t2" type="text" value="2"><BR>
C = <input name="t3" type="text" value="1"><BR>
A+B+C+D = <input name="t4" type="text" value="<not known>"><BR>
<input type="button" name="b" value="GetNewWindow" onclick="doIt()">

</form>
<script type=text/javascript>
function addToA() {
  document.ef1.t1.value = parseInt(document.ef1.t1.value) + 1;
}
function doIt() {
  newWin("http://www.js-examples.com/js/js_window_exf.html");
}
var DispWin; // make global variable!
var intID; // make global variable!
function newWin(urlLoc) {
  _winName = "MyNewWindow";
  _info =  "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=auto,resizable=yes,dependent,height=300,width=420,left=100,top=100";
  DispWin=window.open(urlLoc,_winName,_info);
  intID = setInterval("waitForIt()",300); // 300 milli-secs.
}
function waitForIt() {
  var _v;
  if (DispWin.document.f2.h1.value != "") {
    _v = DispWin.document.f2.t1.value;
    document.ef1.t4.value = parseInt(document.ef1.t1.value) + parseInt(document.ef1.t2.value) + parseInt(document.ef1.t3.value) + parseInt(_v);
    clearInterval(intID);
    DispWin.close();
  } 
}
</script>

Times Viewed: 1

Leave a Reply

Your email address will not be published. Required fields are marked *