简体   繁体   English

使用javascript的弹出窗口 - 在旧的弹出窗口中打开新的弹出窗口

[英]Popup Window with javascript - open new popup in the old popup window

A snipet:- 狙击手: -

     // listen for clicks, opens a hyperlink attached to the event. //
                 $("#canvas").click(function popMessage(e) {
                     $("#canvas").hide();
                     // hyperlink opens a new window upon click on the bubble
                     return !window.open('About.aspx?info=' + info, "pop", "resizable,width=1000,height=600,");
                 });

This works good. 这很好用。

However, I am thinking of a scenario, where a person opens 10 different pop up windows and gets confused which window was referencing to which click. 但是,我正在考虑一个场景,一个人打开10个不同的弹出窗口,并混淆哪个窗口引用了哪个点击。

Came to mind that I could, only allow one pop up window at a time. 想到我可以,一次只允许一个弹出窗口。

for the first click, a new popup window opens. 首次单击时,将打开一个新的弹出窗口。 for every next click, the old popup window is replaced by the new click. 对于每次下一次单击,旧的弹出窗口将被新的单击替换。

finally when parent page is closed, popup window is closed. 最后当父页面关闭时,弹出窗口关闭。

What kind of property should I be looking at for this concept? 我应该为这个概念寻找什么样的财产?

( to be noted that the address of my target popup is not the same, every time, a small part of the address is a code passed as the 'info' ) (需要注意的是,我的目标弹出窗口的地址不一样,每次,地址的一小部分是作为'info'传递的代码)

Don't you just want to close the old window each time #canvas is clicked? 你是不是只想在每次点击#canvas时关闭旧窗口?

//earlier:
var winPop = false;
// in the click event:

if (winPop) {
    winPop.close();
}
winPop = window.open('About.aspx?info=' + info, "pop", 
    "resizable,width=1000,height=600,");

And to close it later: 并在以后关闭它:

window.onbeforeunload = function(e) {
    if (winPop) {
        winPop.close();
    }
};

Ok I know you request a different answer but maybe this can be a second approach for solve your problem and also try to avoid the "pop up blocker from the browsers" and confuse the user. 好的,我知道你要求一个不同的答案,但也许这可能是第二种方法来解决你的问题,并试图避免“从浏览器弹出阻止”和混淆用户。 My two cents 我的两分钱

Is a basic example to make a modal pop up using an iframe. 是使用iframe弹出模式的基本示例。 http://jsfiddle.net/G8Cnh/ http://jsfiddle.net/G8Cnh/

HTML HTML

<div class="popup" style='display:none'>
    <i>X</i>
    <iframe style="width:100%; height:100%;" border="0" src="http://jsfiddle.net/"></iframe>
</div>
<a href="javascript:void(0)">open</a>

JS JS

$(document).on("click","a",function(){
 $(".popup").fadeToggle();
});

$(document).on("click","i",function(){
 $(".popup").fadeOut();
});

CSS CSS

.popup{
    width:470px;
    top:50%;
    margin-top:-225px;    
    left:50%;
    margin-left:-225px;
    height:54%;
    background:#F60;    
    position:absolute;
    z-index:100;
    opacity:.8;
    padding:10px;    
}

.popup i{
    position:absolute;
    display:block;
    background:#FFF;
    border:1px solid #CCC;
    padding:5px;
    font-family:verdana;
    font-size:10px;
    left:100%;
    width:15px;
    hegith:15px;
    border-radius:50%;
    margin-left:-50px;
    text-align:center;
}

.popup i:hover{
    background:#F60;
    color:#FFF;
    cursor:pointer;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM