Thanks Duncan but I was after something a bit different. I am not wanting to load another page whenever someone leaves the site - I think that this is the thread you think I am referring to.
I want an onClose function to run when I close a popup window but I don't want to have to add onClose="whatever()" into the <body> tag as this bit of code is used widely throughout the site. Instead I would like to just set the onClose function for the window in JavaScript later on in the page. This way I just add the JavaScript to the cfm file that is only used in one place instead of changing a file that is used through the site. Giles Roadnight http://giles.roadnight.name -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: 23 January 2003 15:24 To: [EMAIL PROTECTED] Subject: Re: [ cf-dev ] OT: onUnload / onClose setting after <body> 1: Well, the only way I can think of doing this without having to alter ANY of your links AT ALL is something like ... - Have a BODY onUnLoad function on every page to launch your survey window (so that the survey page launches when you exit every page) - On your survery pop-up page have some javascript to close the window if it's an internal link ... if (window.opener.location.host=="your.domain.com") { window.close(); } ... that way the survey pop-up would close itself if the opening page is still in your domain. The only problem would be that the user would see the survey page flash on, then off again, but you could get around this as well by opening the survey window off-screen (e.g. window.open('survey.cfm','SurveyWindow','top=2000,left=2000') ), and then using window.moveTo() in your survey page so that if it doesn't close itself, it moves itself somewhere where the people can see it. 2 (by you giles!): That can be done quite simply with javascript can't it? Just have an onUnload function and if you don't want the window to be closed return false: onUnload=" return checkWindowClose()" function checkWindowClose(){ if (windowCanBeClosed){ return true; } else { return false; } } Duncan Cumming IT Manager http://www.alienationdesign.co.uk mailto:[EMAIL PROTECTED] Tel: 0141 575 9700 Fax: 0141 575 9600 Creative solutions in a technical world ---------------------------------------------------------------------- Get your domain names online from: http://www.alienationdomains.co.uk Reseller options available! ---------------------------------------------------------------------- ---------------------------------------------------------------------- "Giles Roadnight" To: <[EMAIL PROTECTED]> <giles@roadni cc: ght.name> Subject: [ cf-dev ] OT: onUnload / onClose setting after <body> 01/23/03 03:19 PM Please respond to dev I remember a discussion on this a while back but can't find it in the archive, on Google or in my mail box. Did we every come up with a way of setting onClose or onUnload after the <body> tag? The head of the document is shared across the whole site so if possible I don't want to fiddle with that to set an onClose event handler so it would be very nice if I could just set it in Javascript. I have tried variations of the following: window.onCLose= "alert('closing')"; document.onCLose= "alert('closing')"; body.onCLose= "alert('closing')"; document.body.onCLose= "alert('closing')"; none of which work. Thanks Giles Roadnight http://giles.roadnight.name -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED] -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED] -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED]
