Solved

Disable parent window while child is open

Posted on 2006-11-02
4
10,000 Views
Last Modified: 2012-06-27
Is there a way to disable the parent window when a child (popup) window is open? Thanks.
0
Comment
Question by:rbichon
4 Comments
 
LVL 22

Expert Comment

by:WMIF
ID: 17863135
put this in the body tag of the child window.

<body onBlur="self.focus();">
0
 
LVL 2

Accepted Solution

by:
amateur83 earned 250 total points
ID: 17863620
Use window.ShowModalDialog(url,org,features)

It will disable user to click on parent unless child is terminated.
0
 
LVL 30

Expert Comment

by:third
ID: 17864571
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now