kabichan kabichan - 1 year ago 58
ASP.NET (C#) Question

Close iframe from child page with https

I've been googling to figure this out but I just can't find any information on this.

I have a .aspx page that is displayed within iframe of a php parent page.

When a button is clicked on the .aspx page, I close the iframe to go back to the php parent page, and here's the code I use:

void btnDone_ServerClick(object sender, EventArgs e)
Page.ClientScript.RegisterStartupScript(GetType(), "CLOSEWINDOW", "window.parent.postMessage('closeSurvey', '*');", true);

This was working just fine when I was testing the pages with http, but after I changed both the parent page and the .aspx page to https, this code is not working.

The developer of the parent page said he uses the same code to receive a message from the .aspx page, and no changes have made on the .aspx page either.

Am I missing something here to make it work with https as well?

Answer Source

An iFrame is a window inside a document, you don't "close" it as such... reading the word "modal" , I guess you're using some kind of lightbox system that actually creates an iframe on the fly to display outside source in a lightbox.

So what you actually try to do is closing a lightbox, and you won't be able to do it cause https will prevent you to access an element from the parent page from the child page, while http lets you do this.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download