brandonpowell
asked on
Closing a popu up and opening a new web page
Hello,
I have a pop up that launches when a person leaves my site to collect their
contact info. On this pop up I have a simple form that collects the persons
first and last name and email address in a form.
Once the person fills out the form and submits it, how can I have a referral
page load in the browser as a maximized window without launching a new
browser?
Thanks for your help!
Sincerely,
Brandon Powell
I have a pop up that launches when a person leaves my site to collect their
contact info. On this pop up I have a simple form that collects the persons
first and last name and email address in a form.
Once the person fills out the form and submits it, how can I have a referral
page load in the browser as a maximized window without launching a new
browser?
Thanks for your help!
Sincerely,
Brandon Powell
What is the difference between a browser and a window?
ASKER
What I am looking to do is when a visitor leaves my site a pop up window will appear asking
the user to join my newsletter and submit his/her name and email address. After the user
submits his/her information I want that pop up to close, and the visitors browser to load to
my referral.cfm page. How can I do this?
I guess to answer your question, nothing. I am referring to them as one and the same.
Sincerely,
Brandon Powell
the user to join my newsletter and submit his/her name and email address. After the user
submits his/her information I want that pop up to close, and the visitors browser to load to
my referral.cfm page. How can I do this?
I guess to answer your question, nothing. I am referring to them as one and the same.
Sincerely,
Brandon Powell
What I do is start my popup window template newsletter join form something like this:
<form action="http://#CGI.SERVER_NAME##CGI.SCRIPT_NAME#"
so that it calls itself. At the top of my popup window template I have this:
<!--- Have we called ourselves? --->
<cfif NOT CompareNoCase(ListFirst(CG I.HTTP_REF ERER, '?'), 'http://' & CGI.SERVER_NAME & CGI.SCRIPT_NAME)>
<cfoutput><script type="text/javascript">
/* We have called ourselves, so the work must've already been done by the newsletter join action code above this code*/
window.close();
opener.location.href = "referral.cfm?CFID=#CFID#& CFTOKEN=#C FToken#";
</script></cfoutput>
<cfabort>
</cfif>
so that all it displays after you push the submit button is a script telling the window to close and telling its opener to relocate. In the onClose() event of the parent window I have this:
function newWindowMenu(popUpURL, popUpWidth, popUpHeight) {
/* creates a new resizable, scrollable, centered window that
can be closed and reopened without spawning errors. */
var windowLeft = (screen.availWidth - popUpWidth)/2;
var windowTop = (screen.availHeight - popUpHeight)/2;
// sigh...
var params1 = "left=" + windowLeft + ",top=" + windowTop;
var params2 = ",screenX=" + windowLeft + ",screenY=" + windowTop;
var params3 = ",width=" + popUpWidth + ",height=" + popUpHeight;
var params4 = ",toolbar=0,location=0,dir ectories=0 ,status=0" ;
var params5 = ",menubar=1,scrollbars=1,r esizable=1 ";
var theRest = params1 + params2 + params3 + params4 + params5;
var popUp = window.open(popUpURL, "Link", theRest, "focus();");
try {
if(popUp.opener==null) {
popUp.opener = window;
}
}
catch(e) {
}
popUp.focus();
}
window.onclose = newWindowMenu('popup_windo w_template _newslette r_join_for m.cfm', 500, 300);
so that the parent window has an opener attribute that I can refer to in the child window.
<form action="http://#CGI.SERVER_NAME##CGI.SCRIPT_NAME#"
so that it calls itself. At the top of my popup window template I have this:
<!--- Have we called ourselves? --->
<cfif NOT CompareNoCase(ListFirst(CG
<cfoutput><script type="text/javascript">
/* We have called ourselves, so the work must've already been done by the newsletter join action code above this code*/
window.close();
opener.location.href = "referral.cfm?CFID=#CFID#&
</script></cfoutput>
<cfabort>
</cfif>
so that all it displays after you push the submit button is a script telling the window to close and telling its opener to relocate. In the onClose() event of the parent window I have this:
function newWindowMenu(popUpURL, popUpWidth, popUpHeight) {
/* creates a new resizable, scrollable, centered window that
can be closed and reopened without spawning errors. */
var windowLeft = (screen.availWidth - popUpWidth)/2;
var windowTop = (screen.availHeight - popUpHeight)/2;
// sigh...
var params1 = "left=" + windowLeft + ",top=" + windowTop;
var params2 = ",screenX=" + windowLeft + ",screenY=" + windowTop;
var params3 = ",width=" + popUpWidth + ",height=" + popUpHeight;
var params4 = ",toolbar=0,location=0,dir
var params5 = ",menubar=1,scrollbars=1,r
var theRest = params1 + params2 + params3 + params4 + params5;
var popUp = window.open(popUpURL, "Link", theRest, "focus();");
try {
if(popUp.opener==null) {
popUp.opener = window;
}
}
catch(e) {
}
popUp.focus();
}
window.onclose = newWindowMenu('popup_windo
so that the parent window has an opener attribute that I can refer to in the child window.
The above code is optimized for IE 6.x and CF 5 and needs to be tweaked a little to get it to work in other environments. Which browsers are you working with? What version of Cold Fusion are you working with?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much for all of your assistance!
Sincerely,
Brandon Powell
Sincerely,
Brandon Powell