[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 337
  • Last Modified:

Refresh a window that is already open from another window

My website is designed using Coldfusion and has 2 places where a user can login:

1.) From my main index page - simple form with username & password text boxes
2.) My Contact Us page - A link (shown below),  from my main index page opens a NAMED window, also with a form with username & password text boxes

<a href="#" onclick="window.open('CEmailus.cfm?visitor=yes','EmailManager','width=600,height=600,scrollbars=yes,resizable=yes,status=yes');return false;" target="_blank">Contact Us</a>

WHAT I AM TRYING TO DO REFERS TO THE 2nd OPTION ABOVE:  If the user chooses to login from the pop-up window, then I need the original window refreshed and logged in as well.

When a user logs in from either of the forms, the username & password variables are passed through a page called "loginauthentication.cfm" and then upon sucessfully validating the variables, they are redirected to the correct page using "CFLOCATION URL=" xxx ".

TO SUM UP:  If a user logs in from the main index page sucessfully, they are redirected to their MAINPAGE and everthing is good.  If they log in sucessfully from the pop-up window,  they are redirected back to the Contact Us MAINPAGE in the pop-up window . . . . I need to take it one step further and have the main index page to be refreshed when the Contact Us MAINPAGE opens so that the MAINPAGE is also logged in.

TRIED: using "onload ='window.location.replace'(URL)" variations within the pop-up window's body tag, but I don't know how to target this to my main index page - I don't know how to refer to it by name and not sure how to use TARGET with window.location.replace.

Any help would be greatly appreciated.

MAX
0
MaxwellTurner
Asked:
MaxwellTurner
  • 4
  • 2
1 Solution
 
Pravin AsarCommented:
You problem seem to check if user has logged in ?

Since you mentioned about cfm, are you managing cf session ? Setting cf session variables
(session.username, session.password, ...)  ?

In such case in application.cfm you can have a check,

To get the parent window of pop up window and reload by force (overriding the cache-control),
you can do

window.opener.reload (true);
 
0
 
Pravin AsarCommented:
<html>
<head>
<title>Open/Close Windows</title>
</head>
<body>
<script language="javascript">
alert ('Loading ..');
</script>
<p>
This is a test page.
<br>1. Click on "Open Window."
<br>This opens same document on new window.
<br>
<br>2. Click on "Open Window" in newly window.
<br>This opens same document on another window.
</p>
<form>
<input type="button" value="Open Window" onClick="window.open (window.location.href, 'nw',  'width=400, height=400');">
<input type="button" value="Refresh Parent Window" onClick=" window.opener.reload(true);">
</form>
</body>
</html>
0
 
MaxwellTurnerAuthor Commented:
Hi, thanks for the replies.  Although I've been working with Coldfusion for a number of years, I am not very familiar cf sessions and application.cfm - I know they exist but that is about all.  I use cookies to set the user's variables when they log in.

I'm not sure if I explained my problem properly.  I don't want to have to click any button, but rather need this to happen automatically.  Basically, if the user logs in from the CONTACT US page (the small pop-up window that opens from a link on the INDEX page), all I need is for the INDEX page, behind the CONTACT US pop-up, to be refreshed with the following URL:

cmainpage.cfm?view=#view#

1.)  User goes to my website - the first page they see is INDEX.cfm
2.)  User clicks the CONTACT US link to open the pop-up window
3.)  User enters their USERNAME & PASSWORD in the login boxes on the CONTACT US pop-up and submits them
4.)  Upon sucessfully validating their login variables, the CONTACT US page is refreshed showing their name/address etc.. they are now logged in, but only on the CONTACT US pop-up and not on the INDEX page.  If they close the CONTACT US pop-up, they will again need to log into the INDEX page if they want back in.
5.)  As #4 above occurs, I need "cmainpage.cfm?view=#view#" to be sent to the INDEX.cfm page which will log them in there as well, so that if they close the CONTACT US pop-up, they will still be logged into the site.

As I already mentioned earlier, I have tried to use:

<body onload="window.location.replace('Cmainpage.cfm?view=#view#')"> on the CONTACT US pop-up, but I do not know how to TARGET this to the INDEX page.  The above "onload" code is only executed after sucessful login from the CONTACT US page.

Well, I'm not sure if I explained it much better.  Perhaps if you go to the site it will make more sense.

The site we are talking about here is at www.laservalley.com and you can use:

USERNAME:  samreg
PASSWORD: company
. . . to try log in.

MAX
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Pravin AsarCommented:
Target or parent window of CONTACT US window, ( I as posted earlier )  is : window.opener



In you case it will be :

window.opener.location.replace('Cmainpage.cfm?view=#view#');

0
 
MaxwellTurnerAuthor Commented:
My apologies - you are correct and it works perfectly!!  I just put the above line in an OnLoad= statement and it does exactly what I was try to accomplish.  So very simple!

Thank you very much for your help . . . . and patience;)

MAX
0
 
Pravin AsarCommented:
You are welcome!

Thanks,

_PA
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now