You must Sign In to post a response.
  • Category: JavaScript

    Hide webpage you are viewing is trying to close popup

    Hi,

    I am opening the same page in popup using window.open.

    I used window.close() method to close the previous page. when I do so I am getting the popup "webpage you are viewing is trying to close ".

    The popup should not be shown to the user. Please help me in get rid of this popup window.


    Thanks
  • #768175
    Hi,

    This is actually a security feature which is available for explorer and other site when someone try to accidently click on close it should not close abruptly.
    But we have many solution for this to solve programmatically.


    //For Close window screen
    window.open('', '_self', '');
    window.close();



    We can also use response Write method to make it work,

    Response.Write("<script language=\"JavaScript\">window.open('','_self','');window.close(\"" + "" + "\");</script>");


    But I feel method 1 was better than method 2.

    Thanks,
    Mani

  • #768177
    first thing is, you can not close the page which is parent, cause you have open a child page from client,
    Your JavaScript code can only close a window without confirmation that was previously opened by window.open(). This is an intentional security precaution because a script running on a webpage does not own the window, and by closing it discards the browsing history in that window.
    The workaround is to either have a "welcome page" or otherwise some sort of page that pops up the window you want to close with window.open in the first place, or to tell your users to modify their browser security settings to allow your application to close their windows.

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]


Sign In to post your comments