ChrisGaelic
asked on
How to create a popup login panel that closes and refreshes the referring page when login is successful
I want to create a popup login panel using ColdFusion and Javascript and have the popup window closed and the referring page refreshed when the login is successful.
I can already do this if the referring window is a named window so that I can simply use a url target with the same name to get back to the referring page. However this requires that the referring page has already been opened using a named url target. I want to be able to refresh the referring window without it being previously named.
Is there some javascript that will run when the login validation is done and refresh the referring page and then close the login popup panel?
Chris Gaelic
I can already do this if the referring window is a named window so that I can simply use a url target with the same name to get back to the referring page. However this requires that the referring page has already been opened using a named url target. I want to be able to refresh the referring window without it being previously named.
Is there some javascript that will run when the login validation is done and refresh the referring page and then close the login popup panel?
Chris Gaelic
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Anand, it worked a treat - the only thing you forgot was to add the brackets on the window.close - should be window.close().
Chris, thanks for your input - I tried it, but couldn't get it to work.
Chris, thanks for your input - I tried it, but couldn't get it to work.
Well its more important for me to pass teh logic & the idea ... mistype can happen anytime :)
thanx for teh "B"
Cheers
Anand
thanx for teh "B"
Cheers
Anand
Well its more important for me to pass teh logic & the idea ... mistype can happen anytime :)
thanx for teh "B"
Cheers
Anand
thanx for teh "B"
Cheers
Anand
anandkp:
I know it's been awhile but i found this post and I am doing the same thing.
Q: does it matter where in the page the script is located physically in the popup login window?
In your case (on a successful login) the Browser will be returned (see code snipit). The script would be in line in the BODY after the FORM. I'm not a JS guru so is this OK DOM wise?
hefterr
I know it's been awhile but i found this post and I am doing the same thing.
Q: does it matter where in the page the script is located physically in the popup login window?
In your case (on a successful login) the Browser will be returned (see code snipit). The script would be in line in the BODY after the FORM. I'm not a JS guru so is this OK DOM wise?
hefterr
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login Popup</title>
</head>
<body>
<FORM NAME="frm" ACTION="login.cfm" METHOD="post">
<INPUT TYPE="Text" NAME="user">
<INPUT TYPE="Password" NAME="pwd">
<INPUT TYPE="Submit">
</FORM>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"><!--
window.opener.location.replace('loginsuccess.cfm');<!--- new page u want to redirect to --->
window.close();
//-->
</SCRIPT>
</body>
</html>
you can access the opening window by using he self.opener property:
<cfif loginIsSuccessFull>
<script language="JavaScript">
self.opener.location href='whateverpage.cfm'; // refresh opener window
self.close(); // close this window
</cfscript>
</cfif>
HTH,
Chris