Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating a pop-up login window.

    OK, I hope I can expalin what I want to do.

    I have got a page on my website which has a log-in button, when this button is clicked I want a window to pop-up which enables the user the login. After the have typed in their username and password and it has been confermed I want the popup window to close autmatically, or stay there to let the user try again if the information they entered was wrong.

    Now I know this bit is possible, but I would like to take it further if possible:

    This leaves the user on the page where they clicked the log-in button. After the log-in window closes I want this page to change to another page (not loading another window). SO at the end of it the user hasn't had to open or close any windows and they end up with only one window open.

    I know the first bit is possible but I am not sure about the second bit.

    I have got some code for opening and closing windows:
    Open:
    Code:
    <script type="text/javascript"> 
       function openwindow() { 
       window.open ("./loginpage.php","openwindowname","width=200,height=200,scrollbars=no,resizable=no"); 
       } 
    </script>
    Close:
    Code:
     
    
    <script type="text/javascript"> 
       function closewindow() { 
       window.close() 
       } 
    </script>
    Can anyone help me with creating this. Just incase you need to know I will be using php for the logon system.

  • #2
    Regular Coder
    Join Date
    Sep 2005
    Posts
    535
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You want to use the opener property of window... Change your close function to:
    Code:
    <script type="text/javascript"> 
       function closewindow() {
       // Make sure user didn't close the main window! 
       if ((window.opener) && (!window.opener.closed)) 
       { window.opener.location="openingPage.php"; }
       // Perhaps add code to open new window to opening page if opener is closed
       window.close() 
       } 
    </script>
    Here's a nice tutorial on something similar to what you want to do.
    If you want answers, write a smart question.

    Yes, someone probably does know how...

    Oh, and if you want to learn, STFW!

  • #3
    New Coder
    Join Date
    Aug 2006
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cool, thanks. That is just what I needed.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •