简体   繁体   中英

how to close popup window from asp.net mvc

I want to close some html popup windows. I have static site, which creates popup windows. These windows have a submit button, which sends a POST request to asp mvc app. This app works well and return View() (Index page with message "Ok". And Button "Close").

When I click on Close button- nothing happens.

My code:

  <body>
    <button type="button" id="btn" onclick="window.parent.jQuery('#btn, #m_window').hide('slow');">Close</button> 

   
<!--   <button type="button" id="btnFoo" onclick="$("#btnFoo, #m_frame").live("click", function(){
    $("#mistake").remove();
});  ">Close form </button>
   -->
</body>

m_frame- frame of popup window. mistake- div of popup window.

Please, tell me how to close this popup window?

window.close() doesn't work.

PS at js script (when popup creates) I write:

$("#btn",#m_window").live("click",function(){
var p = parent;
 var win = p.document.getElementById('mistake');
 win.parentNode.removeChild(win);
});

But it doesn't works too.

Try this

<script>
    $(document).ready(function () {
        $("#displayinmodal").dialog({
            autoOpen: true,
            modal: true,
            buttons: {
                "Close": function () {
                    $("#displayinmodal").dialog("close");
                }
            }
        });
    });
</script>


<div id="displayinmodal">
    Popup demo
</div>

你应该试试:

window.close();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM