Close the browser

  • Thread starter Thread starter Randy
  • Start date Start date
R

Randy

Hello,
I'm trying to find a way to close the browser with out the IE security
message "The Web page you are viewing is trying to close the window."
message. I know how to close the browser using Javascript (window.close())
but I would not like to get this message.
Is there a way to close it in C#?

Thanks
 
I'm trying to find a way to close the browser with out the IE security
message "The Web page you are viewing is trying to close the window."
message. I know how to close the browser using Javascript (window.close())
but I would not like to get this message.
Is there a way to close it in C#?

Controlling the browser is a client-side behavior, so you have to use
javascript. And whether or not you get those types of errors is entirely
dependant on the browser. Typically, you can close any window you open, but
not ones that the user has opened themselves.

-Darrel
 
Hello Randy,

Prior to calling window.close, set window.opener to a non-null value. Ex:

window.opener = this;
window.close();
 
Back
Top