Refresh a window that is already open from another window

Posted on 2006-05-17
Last Modified: 2008-01-16
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="'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.

Question by:MaxwellTurner
    LVL 28

    Expert Comment

    by:Pravin Asar
    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);
    LVL 28

    Accepted Solution

    <title>Open/Close Windows</title>
    <script language="javascript">
    alert ('Loading ..');
    This is a test page.
    <br>1. Click on "Open Window."
    <br>This opens same document on new window.
    <br>2. Click on "Open Window" in newly window.
    <br>This opens same document on another window.
    <input type="button" value="Open Window" onClick=" (window.location.href, 'nw',  'width=400, height=400');">
    <input type="button" value="Refresh Parent Window" onClick=" window.opener.reload(true);">
    LVL 1

    Author Comment

    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:


    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 and you can use:

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

    LVL 28

    Expert Comment

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

    In you case it will be :


    LVL 1

    Author Comment

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

    LVL 28

    Expert Comment

    by:Pravin Asar
    You are welcome!



    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (, typical array handling might look like this: (CODE) B…
    JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    745 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

    16 Experts available now in Live!

    Get 1:1 Help Now