我有下面的代码片段打开一个子窗口,应留在父窗口的顶部儿童弹出窗口
"var a = window.open('" + url + "', '_blank','height=400,width=400,status=yes,toolbar=no,menubar=no,location=no');";
然而,弹出窗口被打开和未显示父窗口的顶部。
我想保留子窗口堆叠,并且不应允许其他子窗口打开,直到关闭已打开的子窗口弹出窗口。
此问题仅在IE浏览器中。
我有下面的代码片段打开一个子窗口,应留在父窗口的顶部儿童弹出窗口
"var a = window.open('" + url + "', '_blank','height=400,width=400,status=yes,toolbar=no,menubar=no,location=no');";
然而,弹出窗口被打开和未显示父窗口的顶部。
我想保留子窗口堆叠,并且不应允许其他子窗口打开,直到关闭已打开的子窗口弹出窗口。
此问题仅在IE浏览器中。
$(document).ready(function(){
$('#popup-btn').click(function(){
setTimeout(function(){
$('#popup').css('display','block');
},10);
});
});
#parant{
width:300px;
height:300px;
background:#ff8800;
margin:10px auto;
border-radius:15px;
}
#popup{
display:none;
width:300px;
height:300px;
background:#ff8800;
margin:10px auto;
border:1px solid blue;
border-radius:15px;
}
.name{
width:100%;
height:50px;
background:blue;
color:#fff;
text-align:center;
border-radius:15px 15px 0px 0px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="popup">
<div class="name">Child Popup</div>
</div>
<div id="parant">
<div class="name">Parant Popup</div>
<button id="popup-btn">POPUP</button>
</div>
我已经显示的代码片段不会支持jQuery,它只会支持Javascript。谢谢 – user75ponic
我必须通过javascript代码,如下所示'String javascript = “var a = window.open('”+ url +“','a','height = 400,width = 400,status = yes,toolbar = no,menubar = no,location = no');“;' – user75ponic
你想在JavaScript中输入代码吗 –
试试这个..
定义 '顶'
var a = window.open('" + url + "', '_blank','height=400,width=400,status=yes,toolbar=no,menubar=no,location=no,top=0,left=0');
请参考以下链接
https://developer.mozilla.org/en-US/docs/Web/API/Window/open
但是,我试过这个,不会停留在父窗口的顶部。 – user75ponic
请参阅此。这可能会有帮助。 http://stackoverflow.com/questions/13965584/how-to-make-child-window-stay-on-top –
<script>
function popup(){
document.getElementById('pop-div').style.display="block";
}
</script>
<body>
<div style="width:100px; height:100px;display:none;" id="pop-div"></div>
<button onclick="popup();">pop</button>
</body>
''不应该允许其他子窗口打开,直到我关闭已打开的子窗口弹出窗口。“'我不认为这是可能的(或道德的)。以及控制您的窗口是否在父窗口之上。 –
这可能有帮助 - http://stackoverflow.com/questions/5660700/javascript-to-open-popup-window-and-disable-parent-window –