Close Shadowbox and submit form

4 messages Options
Embed this post
Permalink
imperiumza

Close Shadowbox and submit form

Reply Threaded More More options
Print post
Permalink
I have a page with a iframe that this call a new form opening a shadowbox. I using this code provieded by Wizzud :

<script type="text/javascript">
        var sbx = window.parent.Shadowbox;
        function openTopSBX(el){
          if(sbx){
                sbx.open( { content : el.href
                                           , player : 'iframe'
                                           , title : el.title||''
                                           , height : 650
                                           , width : 650
                                           , modal : true
                                           //could include width/height/options if desired
                                           }
                                        );
                return false;
          }
          else{ //no Shadowbox in parent window!
                return true;
          }
        }
</script>

this code works fine, this open my form and I can submit the form, but the URL redirected appear in the same Shadowbox window and not close the window.
When I use in the iframed page this code:

window.parent.Shadowbox.close();

this close the window but don't submit the form.

Can you help me how to close the window submiting the form??

Thanks a lot

P.D: Sorry by my bad english
Wizzud

Re: Close Shadowbox and submit form

Reply Threaded More More options
Print post
Permalink
The script you have posted enables the following...

  Page A
    iframe[1], containing Page B (has the posted script)

Then, Page B tells Page A to open Page C (containing the form) in a Shadowbox iframe...

  Page A
    iframe[1], containing Page B (has the posted script)
    iframe[2], containing Page C (the form, with a standard submit to itself)

When the form on Page C is submitted using a standard submit, the resultant page will appear in the current frame, ie. iframe[2]. My (limited) understanding is that the resultant page may be Page C again - or similar - (if the form submittal was invalid), or Page D (if the form submittal was valid). If Page D is the resultant page (ie. the form was valid) then you want it open in iframe[1] instead of iframe[2]?

To do that, you could return a different page, Page E, from a valid submittal. Page E runs a script located on Page A. That script on Page A closes its Shadowbox (iframe[2]), and then changes the src of iframe[1] to Page D. (The url to Page D can be returned as part of Page E, and then passed to Page A when calling the script).

This is all complicated by the fact that you have Shadowbox running from the top frame, but with content initially controlled by and subsequently affecting an entirely different iframe. You need to think very carefully about your cross-frame controls, and whether you actually need the different iframes.

This is all based on my limited understanding of what you are trying to achieve, which may be incorrect!
Combine literacy with curiosity and a whole world of information opens up to you
Josue

Re: Close Shadowbox and submit form

Reply Threaded More More options
Print post
Permalink
In reply to this post by imperiumza
after much searching i bumped into the solution:


 
<form name="loginform" id="loginform" action="<?=$blogurl ?>/wp-login.php" method="post" onsubmit="window.parent.Shadowbox.close();">

hope this helps

the onsubmit part is the trick :p
shakti_prem

Re: Close Shadowbox and submit form

Reply Threaded More More options
Print post
Permalink
This worked for me

    < input type=button value="Close Window" onClick="parent.location.reload();parent.Shadowbox.close();" >