简体   繁体   中英

parent-child window in java script

i want to stop the program flow until i receive input from child window.

code for parent window:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>MainPage</title>
<SCRIPT LANGUAGE="JavaScript">

function openpage(){
window.open("ok.htm","Warning",'fullscreen=0,height=150,width=300,left=500,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,top=200');

//this the place i want my program to wait till i get any  input that is any change in document.fm.w.value form my child window///////
alert(document.fm.w.value);/// alert should contain the new value acorrding to selection of button in child window////

 }
</SCRIPT>
</head>
<body>
<form name="fm"> 
<input type="hidden" size="40" id="w" value="wwww">
<input type="button" value= "press" id="q" name= "q" onclick= "openpage();">
</form>
</body>
</html>

Child window code:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Warning</title>
<SCRIPT LANGUAGE="JavaScript">

function ReturnToMainPage1() {
window.opener.document.fm.w.value = "X"
//self.close();
}
function ReturnToMainPage2() {
window.opener.document.fm.w.value = "O"
self.close();
}

</SCRIPT>
</head>
<body>
<form name="fm"> 
<table id="MessageTable" width="100%">
    <tr>
        <td align="center">
        <input type="button" value= "OK" id="Latest_Version" onclick= "ReturnToMainPage1();"></td>
        <td>View Latest Released Version</td>
    </tr>
    <tr>
        <td align="center"><input type="button" value= "OK" id="Older_Version" onclick= "ReturnToMainPage2();"></td>
        <td>Continue Viewing Obsolete Version</td>
    </tr>

</table>
</form>
</body>
</html>

You almost certainly don't. Synchronous waiting like this is usually a bad idea in web apps.

You could make a modal dialog with jQuery; that sounds like what you want. A new window like yours is designed to be a stand-alone entity for the most part.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM