开发者

Cloase iframe Colorbox with .Net submit button

开发者 https://www.devze.com 2023-03-05 06:57 出处:网络
I have a simpl开发者_开发技巧e login form invoked for a colorbox link and opening in a iframe.

I have a simpl开发者_开发技巧e login form invoked for a colorbox link and opening in a iframe.

<script>
    $(document).ready(function () {

        $(".logincb").colorbox({iframe:true, innerWidth:240, innerHeight:200});

    });
</script>

<li><a href="/login/login.aspx" class="logincb">login</a></li>

The issue I have having is once the user has correctly entered there login details in the ifrmae, which is checked via a post back in the code behind how can I redirect the parent page and close the frame?


With using a .Net buttons in the form is all makes it a bit strange in the end what I did was include the following function in the page

  <script language="javascript" type="text/javascript">

        function closePage() 
        {
            parent.$.fn.colorbox.close(); parent.location = '/support/marketing-media.aspx';
        }

</script>

then called it in the code behind button event using the ClientScript manager.

  if (!ClientScript.IsStartupScriptRegistered("alert"))
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(),"alert", "closePage();", true);
                }

Not really a fan of this as its ugly, but it works..


Use the following to change the location of the parent page:

parent.location.href = "http://newlocation.com";

The iframe would automatically be lost when the parent location changes, so it is not necessary to remove it. But, if you wanted to close colorbox first before changing the parent location, you could do that by binding an action to the cbox_closed event. Example:

parent.jQuery(document).bind('cbox_closed', function(){
    location.href = "http://newlocation.com";
});
0

精彩评论

暂无评论...
验证码 换一张
取 消