|
-
Nov 14th, 2008, 05:14 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] closing browser
Hello, I want to add a link to my page "close the browser", when the user clicks on that link, it will close the browser. Is there an easy way in c#?
-
Nov 14th, 2008, 05:29 PM
#2
Thread Starter
Frenzied Member
Re: closing browser
forgot to mention, I want to use the hyperlink control to close the browser
-
Nov 16th, 2008, 12:58 AM
#3
Re: closing browser
Since this code has to run on the client side (a server cannot tell a browser window to close) the code has to be written in JavaScript.
Not I'm not sure if there is a way to do this in C# that ASP.Net translates into JavaScript but you would essentially put this in your link's address:
Code:
javascript:window.close();
Please note that IE will tell the user that the web page is requesting that the browser window be closed. Some browsers ignore this request completely and only in very few situations will it close without notifying the user (i.e. the user clicks a button and its immediate effect is closing the window).
In my opinion doing this is typically bad form and/or a user experience no-no but there are some cases where I think it's ok (such as a close button on a pop-up).
-
Nov 17th, 2008, 11:22 AM
#4
Re: closing browser
To do it without a warning,
Code:
javascript:window.opener='blah';window.close();
I agree that it's bad for user experience especially if it's on the main page of the site. It's a way of saying "Dear user, you are obviously too stupid to use the X button in your toolbar, so here's a close button for you; now that we're done patronizing, do visit our site more often so that we can treat you like this further."
-
Nov 18th, 2008, 03:04 PM
#5
Thread Starter
Frenzied Member
Re: closing browser
how can I put that into the hyperlink control?
-
Nov 18th, 2008, 03:05 PM
#6
Thread Starter
Frenzied Member
Re: closing browser
Oh nevermind.
Thank you.
HyperLink1.NavigateUrl = "javascript:window.opener='blah';window.close();";
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|