Blog

Share this blog : twitter

Nov 18

Written by: IOTAP ::-- SharePoint Team
Tuesday, November 18, 2008 2:43 PM 

Closing a browser window without the confirmation-prompt.

Closing a browser window without the confirmation-prompt.
If you are closing a page using javascript in IE

window.close();
It will prompt an Microsoft Internet Explorer mesage
 
The Web page your are viewing is trying to close window to avoid/bypass this alert/message,
you need to assign the page you are close with
window.opener = "to some value";
this is because if you want to close a page directly the page should have a opener
thus by assigning the page with a opener value, the page can be close by calling
window.close() subsequently
 
Sample Code:
protected void Button1_Click(object sender, EventArgs e)
{
                string script = "var windowObject = window.self; windowObject.opener = window.self; windowObject.close();";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Close Window", script, true);
}

Tags:

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment   Cancel 


 
 
 

IOTAP is an IT Consulting and Software Services Company with global delivery centers in Mumbai and Chennai, India. We are a Microsoft Gold Certified Partner and use products and technologies like Dynamics CRM, SharePoint, Silverlight, and the .Net platform to create solutions that help our customers connect, communicate and collaborate effectively