• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 10303
  • Last Modified:

Disable parent window while child is open

Is there a way to disable the parent window when a child (popup) window is open? Thanks.
0
rbichon
Asked:
rbichon
1 Solution
 
WMIFCommented:
put this in the body tag of the child window.

<body onBlur="self.focus();">
0
 
amateur83Commented:
Use window.ShowModalDialog(url,org,features)

It will disable user to click on parent unless child is terminated.
0
 
thirdCommented:
ShowModalDialog is AFAIK, IE only. I suggest using a popup div. Like this code of Michel.


<html>
<head>
<style>
.parentDisable {
z-index:999;
width:100%;
height:100%;
display:none;
position:absolute;
top:0;
left:0;
background-color: #ccc;
color: #aaa;
opacity: .5;
filter: alpha(opacity=50);  
}
#popup {
width:200;
height:100;
position:absolute;
top:200px;
left:200px;
color: #000;
background-color: #fff;
}
</style>
<script>
function pop() {
  document.getElementById('mainDiv').style.display='block';
  return false
}
function hide() {
  document.getElementById('mainDiv').style.display='none';
  return false
}
</script>
</head>
<body">
<input type="text" name="txt1">

<div id="mainDiv" class="parentDisable">
<table border="1" id="popup"><tr><td>   Please <a href="#" onClick="return hide()">click</a></td></tr></table>
</div>

<h1>Hello</h1>
Place a DIV, first thing, on the main page.
z-index:999; width:100%;
height:100%; display:none; position:absolute; top:0; left:0;  
If you feel like getting fancy, you could set the alpha transparency of the
div to like 50 percent or something. Then when you open the other
window, first show this div. You will have issues with select boxes
and other buggy things, ... the easiest way to deal with them is to
set them to display:none while the child window is open.
<br><a href="#" onClick="return pop()">Popup</a>

</body>
</html>
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now