Question

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?

Was it helpful?

Solution

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();

OTHER TIPS

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;
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top