our requirement is client wants to know howmany users leaving the main page without entering
data in the application page.at that time we need to show the css popup overlay.

in the following scenarios overlay should pop up.

1)when user leaves the page.(e.g. type other address in the address bar).bascially user shy away from the browser.
2)clicks browser close button.

we will show one css popup overlay(not browser popup) and in the back ground main application will be greyed out.this overlay consists of some text fields and some buttons will be there and parallely in the back ground we will execute AJAX call.

can we accomplish this requirement??is yes how?will it work in all browsers?my concern is how to prevent the browser from closing when css overlay comes up?