开发者

parent-child window in java script

开发者 https://www.devze.com 2023-02-13 02:17 出处:网络
i want to stop the program flow until i receive input from child window. code for parent window: <html>

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" val开发者_高级运维ue="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.

0

精彩评论

暂无评论...
验证码 换一张
取 消