> Hi,
> I have been asked to investigate the possibility of adding the
> functionality
> of an on_close survey to all our sites. It would be a generic survey
> across
> them all.
> This should behave as follows.
> 1) activate when the user leaves the domain - i.e. clicks some where else.
> 2) activate when the user closes the site down.
> How easy is this to achieve? Obviously the onClose is pretty
> straightforward but what about the domain etc.... Any ideas/thoughts.....
> How long would it take to implement this....(1 hour, 2 hours....etc...?)?
I've done this sort of thing -- actually to run a logout script from an
intranet app... Some popup add killers may prevent the survey from
displaying which imho is a good thing since this sort of thing is exactly
what popup killers are designed to combat. The simplest solution I found was
to create a global variable in javascript ( window._staying for instance )
and set it to false, then on any link which remains within the site you add
onclick="window._staying=true;". In the window.onunload() event you add a
function which checks the value of window._staying and launches your survey
if it's false. You want to attach the onclick event to links which stay
withing your domain instead of those which leave the domain, so that the
window.onunload() event can also fire the survey if the user types something
new into the url field of their browser or simply closes the browser. The
hardest part will likely be changing all your links... Although... this
could probably also be done with javascript ( although admittedly, it's a
shotgun ) ... i.e.
function setStaying() { window._staying = true; }
function loademup() {
window._staying = false;
for (x in links) {
xlink = links[x];
xurl = xlinks.href;
if (xurl.toLowerCase.indexOf("#lcase(cgi.http_host)#")==0) {
xlink.onclick = setStaying;
}
}
} window.onload = loademup;
I've done this once before when I wanted to confirm that a user would lose
changes which hadn't been committed to a db... but it wasn't throughout the
app, just on one page...
hth
Isaac Dealey
Certified Advanced ColdFusion Developer
www.turnkey.to
954-776-0046
______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists