#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2006
    Posts
    49
    Rep Power
    11

    Creating a popup 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.
    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 would like to know if this is possible and how to do it.

    Thanks
  2. #2
  3. (,,,)( '.' )(,,,)
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    Looking at my screen
    Posts
    481
    Rep Power
    15
    here is a way to openwindow

    Code:
    <script type="text/javascript">
    	function openwindow() {
    	window.open ("./loginpage.php","openwindowname","width=200,height=200,scrollbars=no,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no,");
    	}
    </script>
    
    <input type="button" onclick="openwindow()" value="Open window">
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2006
    Posts
    49
    Rep Power
    11
    Cool thanks.

    So that's the first part, now I just need to know how to close the window and then re-direct the first page.?
  6. #4
  7. (,,,)( '.' )(,,,)
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    Looking at my screen
    Posts
    481
    Rep Power
    15
    Originally Posted by maxpax
    Cool thanks.

    So that's the first part, now I just need to know how to close the window and then re-direct the first page.?
    Do you use php as well ?
  8. #5
  9. (,,,)( '.' )(,,,)
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    Looking at my screen
    Posts
    481
    Rep Power
    15
    This will close a window

    Code:
    <script type="text/javascript">
    	function closewindow() {
    	window.close()
    	}
    </script>
    
    <input type="button" onclick="closewindow()" value="Close window">
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2006
    Posts
    49
    Rep Power
    11
    Yeah I will be using php for the user logon system and all my pages on my website are php.

    So then if the password is correct the window will automatically close and take the back to the page they started on. And then hopefully redirect them if it is possible.

    But if the password is wrong the popup window will remain to allow the user to try again.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2008
    Posts
    1
    Rep Power
    0

    Unhappy Help!!!


    I would like to have the exact same thing done for a login page....can anyone help us on this?

    Thank you
  14. #8
  15. garish grotesque gargoyle
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2006
    Location
    gracing gargantuan gothic gateways
    Posts
    1,337
    Rep Power
    1037
    are you using AJAX for the login check? otherwise I'm not sure if this will work...

    the basic idea is to use window.opener to address the window that opened the popup, so something like:

    Code:
    <html>
    <head>
    <title>You logged in, you crazy user!</title>
    <script type="text/javascript">
      function redirAfterLogin() {
        window.opener.location.href = 'http://your.website.ext/logged/in/front/page.url';
        self.close();
      }
      onload = setTimeout(redirAfterLogin,1000);
    </script>
    </head>
    <body>
      <h2>Congrats.  You logged in.  Sending you home now.</h2>
    </body>
    </html>
    BUT, since you're probably submitting a login form in that window, window.opener may not be viable after the login form returns a new page. you'll have to test to see. If you use AJAX for the login, then the page never changes, and window.opener should still be viable. I just don't know if window.opener is retained through http requests. Test, and let us know!

    HTH - derelict
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    1
    Rep Power
    0

    This worked for me


    You need to use ajax. If you want to try building yourself, see tinybox which is a javascript popup box. You can show the login form in a popup box using it.

    If you don't want to go through all the trouble, a ready-made solution is available from here. Do go through the readme file to integrate it easily to any website.
    skipser.toolsbysk.com/p/94/p/general/popup-box-for-login-screen.html

IMN logo majestic logo threadwatch logo seochat tools logo