最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Anyone can close the popup generated by Jquery plugin bPopup, from a child iframe? - Stack Overflow

programmeradmin5浏览0评论

Okay, the story is abit long but hope you can bear with me so that there could be some background to the problem:

I'm developing the registration section for a portal using ASP.NET and to make things nice, I decided to use bPopup from here to load the registration page into the iframe of the calling page (parent page). Now I need a way to close down the iframe after a successful registration so from the codebehind of the registration page (nested in the iframe) I tried a Javascript function from the parent that allows me to do so, here's the function to close the iframe generated by the plugin:

 function bPopup_close() {
         $(".bClose").closePopup();
     return false;
 }

and here's the code behind from the iframe (the function will be called on submit):

    ClientScript.RegisterOnSubmitStatement
        (GetType(), "Javascript", "javascript: window.opener.bPopup_close();");

I wasn't able to close the popup. Interestingly, Firebug showed me that after I clicked the submit button, window.opener was null. Does that mean that the parent was indeed closed? Anyway the popup was still there...

Hope you guys could share some insights on anything similar?

Okay, the story is abit long but hope you can bear with me so that there could be some background to the problem:

I'm developing the registration section for a portal using ASP.NET and to make things nice, I decided to use bPopup from here to load the registration page into the iframe of the calling page (parent page). Now I need a way to close down the iframe after a successful registration so from the codebehind of the registration page (nested in the iframe) I tried a Javascript function from the parent that allows me to do so, here's the function to close the iframe generated by the plugin:

 function bPopup_close() {
         $(".bClose").closePopup();
     return false;
 }

and here's the code behind from the iframe (the function will be called on submit):

    ClientScript.RegisterOnSubmitStatement
        (GetType(), "Javascript", "javascript: window.opener.bPopup_close();");

I wasn't able to close the popup. Interestingly, Firebug showed me that after I clicked the submit button, window.opener was null. Does that mean that the parent was indeed closed? Anyway the popup was still there...

Hope you guys could share some insights on anything similar?

Share Improve this question edited Jul 4, 2013 at 23:40 Yotam Omer 15.4k11 gold badges64 silver badges65 bronze badges asked Nov 22, 2010 at 16:31 fredfred 3192 gold badges5 silver badges17 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 11

I can see that dinbror already answered you on his page :)

@fred: Glad you like it. Are you using the newest version of bPopup?

Solution: Create a function on the page which opens the popup:

function closeBPopup() { $(selector).bPopup().close() }

Then you can trigger it inside your iframe whenever you are done doing your stuff with:

parent.closeBPopup();

After half a day, I finally got it working with:

ClientScript.RegisterStartupScript (GetType(), "blah", "< script type=\"text/javascript\">bclose(); < /script> ", false);

and the code bclose() is:

    function bclose() {
        parent.$("#popup").bPopup().close();
        return false;
    }

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论