2011-02-23 6 views
0

Je veux arrêter le flux du programme jusqu'à ce que je reçoive une entrée de la fenêtre enfant.fenêtre parent-enfant dans le script java

Code

pour fenêtre parent:

<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> 

code fenêtre enfant:

<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> 

Répondre

1

Vous presque certainement pas faire. L'attente synchrone comme celle-ci est généralement une mauvaise idée dans les applications Web.

Vous pouvez créer une boîte de dialogue modale avec jQuery; cela ressemble à ce que vous voulez. Une nouvelle fenêtre comme la vôtre est conçue pour être une entité autonome pour la plupart.

Questions connexes