Solved

How to create a popup login panel that closes and refreshes the referring page when login is successful

Posted on 2003-10-31
6
583 Views
Last Modified: 2013-12-24
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
0
Comment
Question by:ChrisGaelic
6 Comments
 
LVL 17

Accepted Solution

by:
anandkp earned 250 total points
ID: 9656917
<!--- base.cfm --->
<A HREF="javascript:;" TITLE="Search Category" ONCLICK="window.open('Login.cfm','login','scrollbars=no,resizable=no,maximize=no,width=350,height=120,top=225,left=420')">Login</A>Login.cfm


show the user teh login form & on submit - send the data back to the same page [login.cfm]
using CFquery validate teh user againts teh DB like :

<!--- Login.cfm --->
<FORM NAME="frm" ACTION="login.cfm" METHOD="post">
      <INPUT TYPE="Text" NAME="user">
      <INPUT TYPE="Password" NAME="pwd">
      <INPUT TYPE="Submit">
</FORM>

<CFIF IsDefined('user')>
      <CFQUERY NAME="Qry_ValUser" DATASOURCE="Dsn">
            select userid from user where username = '#user#'
      </CFQUERY>
      <CFIF Qry_ValUser.recordcount gt 0><!--- user exists --->
            <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"><!--
                  window.opener.location.replace('loginsuccess.cfm');<!--- new page u want to redirect to --->
                window.close;
                //-->
            </SCRIPT>
      <CFELSE>
            invalid user - enter again.
      </CFIF>
</CFIF>

let me know

K'Rgds
Anand
0
 
LVL 4

Expert Comment

by:procept
ID: 9656942
Hi,

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
0
 

Author Comment

by:ChrisGaelic
ID: 9660148
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.

0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 17

Expert Comment

by:anandkp
ID: 9662011
Well its more important for me to pass teh logic & the idea ... mistype can happen anytime :)

thanx for teh "B"

Cheers
Anand
0
 
LVL 17

Expert Comment

by:anandkp
ID: 9662013
Well its more important for me to pass teh logic & the idea ... mistype can happen anytime :)

thanx for teh "B"

Cheers
Anand
0
 
LVL 1

Expert Comment

by:hefterr
ID: 35945949
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




<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>

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now