I want open window.open
as modal popup.
var features = 'resizable= yes; status= no; scroll= no; help= no; center= yes;
width=460;height=140;menubar=no;directories=no;location=no;modal=yes';
window.open(href, 'name', features, false);
I can use Window.ShowModelDialog()
, but in my child window I am calling parent javascript method. That is not happening with ShowModelDialog().
function CallParentScript(weburl) {
alert(weburl);
if (weburl != null) {
var url = weburl;
window.opener.SelectUserImageCallback(url);
window.close();
return false;
}
}
If I use window.open()
. I can call Parent javascript. But window is not modal.
How to solve this? Can I write something in child popup to always top?
This question is related to
javascript
asp.net
css
That solution will open up a new browser window without the normal features such as address bar and similar.
To implement a modal popup, I suggest you to take a look at jQuery and SimpleModal, which is really slick.
(Here are some simple demos using SimpleModal: http://www.ericmmartin.com/projects/simplemodal-demos/)
You can try open a modal dialog with html5 and css3, try this code:
.windowModal {_x000D_
position: fixed;_x000D_
font-family: Arial, Helvetica, sans-serif;_x000D_
top: 0;_x000D_
right: 0;_x000D_
bottom: 0;_x000D_
left: 0;_x000D_
background: rgba(0,0,0,0.8);_x000D_
z-index: 99999;_x000D_
opacity:0;_x000D_
-webkit-transition: opacity 400ms ease-in;_x000D_
-moz-transition: opacity 400ms ease-in;_x000D_
transition: opacity 400ms ease-in;_x000D_
pointer-events: none;_x000D_
}_x000D_
.windowModal:target {_x000D_
opacity:1;_x000D_
pointer-events: auto;_x000D_
}_x000D_
_x000D_
.windowModal > div {_x000D_
width: 400px;_x000D_
position: relative;_x000D_
margin: 10% auto;_x000D_
padding: 5px 20px 13px 20px;_x000D_
border-radius: 10px;_x000D_
background: #fff;_x000D_
background: -moz-linear-gradient(#fff, #999);_x000D_
background: -webkit-linear-gradient(#fff, #999);_x000D_
background: -o-linear-gradient(#fff, #999);_x000D_
}_x000D_
.close {_x000D_
background: #606061;_x000D_
color: #FFFFFF;_x000D_
line-height: 25px;_x000D_
position: absolute;_x000D_
right: -12px;_x000D_
text-align: center;_x000D_
top: -10px;_x000D_
width: 24px;_x000D_
text-decoration: none;_x000D_
font-weight: bold;_x000D_
-webkit-border-radius: 12px;_x000D_
-moz-border-radius: 12px;_x000D_
border-radius: 12px;_x000D_
-moz-box-shadow: 1px 1px 3px #000;_x000D_
-webkit-box-shadow: 1px 1px 3px #000;_x000D_
box-shadow: 1px 1px 3px #000;_x000D_
}_x000D_
_x000D_
.close:hover { background: #00d9ff; }
_x000D_
<a href="#divModal">Open Modal Window</a>_x000D_
_x000D_
<div id="divModal" class="windowModal">_x000D_
<div>_x000D_
<a href="#close" title="Close" class="close">X</a>_x000D_
<h2>Modal Dialog</h2>_x000D_
<p>This example shows a modal window without using javascript only using html5 and css3, I try it it¡</p>_x000D_
<p>Using javascript, with new versions of html5 and css3 is not necessary can do whatever we want without using js libraries.</p>_x000D_
</div>_x000D_
</div>
_x000D_
I agree with both previous answers. Basically, you want to use what is known as a "lightbox" - http://en.wikipedia.org/wiki/Lightbox_(JavaScript)
It is essentially a div than is created within the DOM of your current window/tab. In addition to the div that contains your dialog, a transparent overlay blocks the user from engaging all underlying elements. This can effectively create a modal dialog (i.e. user MUST make some kind of decision before moving on).
Source: Stackoverflow.com