Pop Up functionality when user leaves a site in jsp

Can anyone help me on writing an exit pop-up in a jsp page. Req's-  pop-up has to appear whenever an anonymous user leaves the site and if the suppress pop up is in the uri of the user's session, prevent the pop-up from showing. Thank you.
AnithaEAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrcoffee365Commented:
Exit popups are done with Javascript, generally.  This is a nice site for how to code Javascript exit popups:
http://www.hypergurl.com/popup.html
Basically, you use the OnUnload tag:
<body OnUnLoad="evalForPopup()">
where evalForPopup is a Javascript function which checks some values and either continues with the popup, or not.

In your case, instead of checking the cookie to suppress the popup, you would check the url -- or probably query parameters?

On the other hand, you could generate the page using JSP to either have the OnUnload poup, or not, depending on the information you've stored in the session.

0
AnithaEAuthor Commented:
Hi, Thanks for those useful Hints. One 2 more question- what is meant by Supress the PopUp and how can it be set in a cookie. Should this Exit Pop Up be made a Session Scope one or a Request Scope one in the JSP page. Thanks
0
mrcoffee365Commented:
If you looked at the page I gave the link to above, it explained that the writer wanted to suppress the popup so that it only happened once to one person in any one day.  So they set a date-time stamp in their cookie, and check to see if it's today.  In your case, you must have a way for users to ask that they not get the popup, since you said you can tell from their "uri".  So in your case, you want to suppress the popup based on that.

To suppress the popup means that it doesn't pop up.

The suppression does not happen in the cookie, the value that you read in the Javascript function is set in the cookie.  Then in your Javascript function, you check if there's a value in the cookie that says "do not do exit popup" and you don't do the exit popup.

>Should this Exit Pop Up be made a Session Scope one or a Request Scope one in the JSP page.
Exit popups are handled by Javascript.  So the most that a JSP page could do would be to read the "no popups" value in the cookie, and generate the HTML for the page without the exit popup code.  There's no direct relationship between the cookie and whether bean attributes are in session scope or request scope.  

If you mean should you set a bean value in your code with the cookie information (not really necessary since it's in the cookie, but you could do it for convenience) then I think you have to check it with every page display, which would be Request scope.   But it would work to set it for session, since the cookie would live that long, too.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AnithaEAuthor Commented:
Thank you so much. I did read the stuff in that link but doing so many things it went over my head! I really thank for that prompt and consice answer.
0
mrcoffee365Commented:
You're welcome.  If you need any help with the JSP code, or Javascript code, post another question.

The JSP group is here:
http://www.experts-exchange.com/Programming/Languages/Java/J2EE/JSP/
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.