Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Event to execute javascript function on browser close?

Avatar of Rajkumar Gs
Rajkumar GsFlag for India asked on
JavaScriptC#ASP.NET
18 Comments1 Solution718 ViewsLast Modified:
This is my requirement:-
I want to reload the parent page when user close the popup.

This is the code which I currently have
// Javascript code
function redirect(linkid)
{
    opener.location.href=linkid
    window.close()
}

// Close Button in Popup
 <asp:Button ID="btnClose" runat="server" CssClass="btns"  OnClientClick="javascript:redirect('Group.aspx');"
                                        Text="Close" />

When user click 'Close' button in popup everything works fine as expected.

But I want to execute this javascript even when user close the browser window directly without click on 'Close' button in popup.

I tried in
<body onunload="javascript:redirect('Group.aspx');"  >
But javascript function triggers on every event in the popup !! I mean when user click on 'edit' button in datagrid etc etc)

Could you suggest me, how to sort out this issue ?

Thanks
Raj
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971Flag of Guadeloupe imageMultitechnician
Commented:
This problem has been solved!
Unlock 1 Answer and 18 Comments.
See Answers