close an iframe from itself

close an iframe from itself

Hello,

I have a payment gateway inside an iframe, and when the process finish I want to close it.

My try follows.

In the main document I have this code:
jQuery(document).ready(function(){
     jQuery(document).bind("cleariframe",function(){ alert("remove"); });
});


Expecting to bind the function cleariframe. When it will be launched I will replace the alert with a properly ('#iframeId').remove

In the iframe I have the following code:
jQuery(document).ready(function(){
     jQuery(window.parent).trigger("cleariframe");
});


Expecting to call the parent function cleariframe to close/remove it.

The problem is that nothing happends, no error, no alert box,...

If I could do this I will appreciate a help to do it. If it is not possible to do what I have in mind, I will also appreciate a replay explaining me that this is not possible.

If you want to see the process in real, you can follow this link:
http://pakox.xen.prgmr.com/tatokao/
login as testing user manou/qwerty (user/password)
Click on "Haz un deposito"
Select an amount an use this demo data:
Nº Tarjeta 4548812049400004
Fecha caducidad 12/09
Codigo de seguridad 285
CIP 123456

After the payment process the whole application is reloaded inside the iframe, that's why I want to close it.

This is because I have developed the application with Joomla framework and the URL_OK sent by the payment gateway is a call to the proper component/task, so whole application is loaded inside the iframe. Another approach could be not use a joomla component/task to process the pay_ok but an independent Joomla script, but doing like this, because the way Joomla manages sessions, a new session is created, not recovered from the one I created before with the user and amount information to update the DB if the payment has been acepted.

I will appreciate so much to know the right way to close the iframe from itself if it is possible or just another stratergy to achieve this goal.

I'm stuck long time ago with this issue.

Thank you very much for your time.