Link to home
Start Free TrialLog in
Avatar of HawaiiDragon
HawaiiDragon

asked on

Close IE with C#

I want to be able to close the browser  that the website is running in on a close button press. How do i do this.
this.close();
is not an option. What do I do?
Avatar of prairiedog
prairiedog
Flag of United States of America image

>>>this.close() is not an option
I assume you meant that JavaScript is not an option, right?
Avatar of HawaiiDragon
HawaiiDragon

ASKER

well if you could tell me how to javascript it that would be great. i have no idea
Well, this.close() is JavaScript.
yea I tried that there is no option for it for some reason. Now the button is ina master page is that going to make a diffrence?
 protected void Button5_Click(object sender, EventArgs e)
    {
        
    }

Open in new window

When the button is clicked, do you need to execute some code before closing the window, or just close the window?
I just want to close the window
Is this window a Popup window?
OK, before we go any further, please allow me to give you some information about this.close() or window.close(), or self.close() functions. Any of these functions can be used to close a window, but they are only allowed to be called for windows that were opened by a script using the window.open method. Otherwise, IE will display a prompt asking you if you want to close the window, but FireFox will throw an error in Error Console and will not close the window (not even a prompt). Apparently, it is for the security reason.
yes i even tried in the html code i tried
        <asp:Button ID="Button5" runat="server" Text="Emergency Close" OnClientClick="window.close" />
and it would not work
okay I got it
        <asp:Button ID="Button5" runat="server" Text="Emergency Close" OnClientClick="window.close()" />  
But... how do you fool IE to not put up the warning label????
i.e.    The webpage you are viewing is tryin to close the window.
        Do you want to close this window?
                     yes       no
ASKER CERTIFIED SOLUTION
Avatar of prairiedog
prairiedog
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
cool thanx
window.close only works if the window is a popup window triggered by JavaScript window.open function.
There is a way to do it I just did if you want to know how email me matthewshier@gmail.com
Unfortunately it is aginst the EE membership agreement to get an answer through ways other than here. Thanks though.
whoops! Well thats good to know! Thank you for all your help!