Asp javascript: How to save data when closing a window

Source: Internet
Author: User

How to save data when closing the window <SCRIPT language = "javascript">
Function IfWindowClosed ()
{
Var win = null;
Try
{
Window. opener. name = "ss ";
If (window. opener. name! = "Ss ")
{
Win = window. open ("quit. asp", "", "width = 100, height = 100, left = 10000, top = 10000 ");
Window. setTimeout ("window. close ();", 0 );
}
Window. opener. name = "";
}
Catch (e)
{
Win = window. open ("quit. asp", "", "width = 100, height = 100, left = 10000, top = 10000 ");
Window. setTimeout ("window. close ();", 0 );
}
}

Window. setInterval ("IfWindowClosed ()", 100 );
Window. setTimeout ("window. close ();", 510 );
</SCRIPT>
---------------

Use the onunload Event to open the above File

Quit. asp is the data storage file. The above file is used to check whether the window is closed or refreshed.

Ie5 is compatible. It was previously determined by window. opener. closed. ie5 does not support the closed attribute.
The above code has been tested many times and no problem is found for the time being.

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.