Close the window and destroy the session immediately.

Source: Internet
Author: User
Code As follows: 1 <% @ Page Language = " C # " Autoeventwireup = " True " Codefile = " Default2.aspx. CS " Inherits = " Default2 "   %>
2
3 <! Doctype HTML public " -// W3C // dtd xhtml 1.0 transitional // en "   " Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
4
5 < HTML xmlns = " Http://www.w3.org/1999/xhtml "   >
6 < Head runat = " Server " >
7 < Title > No title page </ Title >
8 < Script Language = " Javascript " >
9
10 Function closepage ()
11 {
12 If (Window. screenleft > = 10000   && Window. screentop > = 10000 ) | Event . Altkey)
13   {
14Window. Location. href="/Closepage. aspx" 
15}
16 }
17
18 </ Script >
19 </ Head >
20 < Body onUnload = " Closepage () " >
21 < Form ID = " Form1 " Runat = " Server " >
22 < Div >
23 < ASP: button ID = " Button1 " Runat = " Server " Onclick = " Button#click " Text = " Button "   /> </ Div >
24 </ Form >
25 </ Body >
26 </ Html >

The page_load on the closepage. CS page is destroyed as follows: Session. Abandon ();
Note: The onUnload Event is also triggered when the page is refreshed. Therefore, you need to determine whether to close the page and then destroy the session. That is:
If (window. screenleft> = 10000 & window. screentop> = 10000) | event. altkey)
{

}

0 0

0

(Please Article Make comments)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.