最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - How to close window on browser (ASP.NET MVC) - Stack Overflow

programmeradmin12浏览0评论

Good day!

EDIT: I have simple static site and script in it: when i press Cntrl-Enter- open popup window.And then after press -Submit- i send post request into my mvc app.

I write simple asp mvc app , result of it work- send message at opened popup window:All done.Press button to close it".

Return result into this window:

public ActionResult Index()
    {
        ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
        Response.CacheControl = "no-cache";
        Response.AddHeader("Pragma", "no-cache");
        Response.Expires = -1;
        Response.AddHeader("Cache-Control", "no-cache");

        return View();
    }

How i try to close this window on client:

<script type="text/javascript">
function OnCloseForm()
{

    this.window.close();
}

But i cant do that! I know,that i should use window.open() and then i can do window.close(). But how to close popup window at my case?

Thank you!

P.S. Unfortunatelly- window.close() not works.

Good day!

EDIT: I have simple static site and script in it: when i press Cntrl-Enter- open popup window.And then after press -Submit- i send post request into my mvc app.

I write simple asp mvc app , result of it work- send message at opened popup window:All done.Press button to close it".

Return result into this window:

public ActionResult Index()
    {
        ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
        Response.CacheControl = "no-cache";
        Response.AddHeader("Pragma", "no-cache");
        Response.Expires = -1;
        Response.AddHeader("Cache-Control", "no-cache");

        return View();
    }

How i try to close this window on client:

<script type="text/javascript">
function OnCloseForm()
{

    this.window.close();
}

But i cant do that! I know,that i should use window.open() and then i can do window.close(). But how to close popup window at my case?

Thank you!

P.S. Unfortunatelly- window.close() not works.

Share Improve this question edited Jan 17, 2014 at 11:13 Admiral Land asked Jan 17, 2014 at 10:50 Admiral LandAdmiral Land 2,4928 gold badges47 silver badges95 bronze badges 1
  • 1 possible duplicate of How to close current tab in a browser window? – Dr Rob Lang Commented Jan 17, 2014 at 10:53
Add a ment  | 

2 Answers 2

Reset to default 2

Here is an example Link

<body>
    <script type="text/javascript">
        window.close();
    </script>
</body>

You should just call window.close() (without the this in front)

发布评论

评论列表(0)

  1. 暂无评论