Close browser window.
-
Hi guys am trying close the browser window once user clicks button 'Exit browser', in asp.net I tried the following but it won't work
string scriptor = "<script type=javascript>window.close();</script>";
if(!ClientScript.IsStartupScriptRegistered("clientScript"))
{
ClientScript.RegisterStartupScript(Page.GetType(), "clientScript", scriptor);
}and
Response.Write("<script type=text/javascript>self.close()</script>");
this is in my click event Does anyone know how i can fix this one? please help
-
Hi guys am trying close the browser window once user clicks button 'Exit browser', in asp.net I tried the following but it won't work
string scriptor = "<script type=javascript>window.close();</script>";
if(!ClientScript.IsStartupScriptRegistered("clientScript"))
{
ClientScript.RegisterStartupScript(Page.GetType(), "clientScript", scriptor);
}and
Response.Write("<script type=text/javascript>self.close()</script>");
this is in my click event Does anyone know how i can fix this one? please help
What happens if you add an 'onclick' attribute to your button as set is equal to window.close(); Seems a bit unnecssary to require a postback to the server for this.
-
Hi guys am trying close the browser window once user clicks button 'Exit browser', in asp.net I tried the following but it won't work
string scriptor = "<script type=javascript>window.close();</script>";
if(!ClientScript.IsStartupScriptRegistered("clientScript"))
{
ClientScript.RegisterStartupScript(Page.GetType(), "clientScript", scriptor);
}and
Response.Write("<script type=text/javascript>self.close()</script>");
this is in my click event Does anyone know how i can fix this one? please help
Try this:
string script = "window.close();";
System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "CloseWindow", script, true);
// In case no ScriptManager then:
//Page.RegisterClientScriptBlock(Page, this.GetType(), "CloseWindow", script, true);This should work.
-
Try this:
string script = "window.close();";
System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "CloseWindow", script, true);
// In case no ScriptManager then:
//Page.RegisterClientScriptBlock(Page, this.GetType(), "CloseWindow", script, true);This should work.
Hi thanks Sandeep, Well, this works for IE but unfortunately it won't work for Fire Fox for some reason...