SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Forms

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2001
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Forms

    In a 'Login' FORM for example, how can I close the popup window which the form is in and redirect the client to a new window at the same time.

    Example code :

    <script language="javascript">
    function closewindow()
    {window.close('loginwindow.htm');}
    </script>

    <form name=form1 method=Post action='javascript:closewindow()'>

    I can close the window by calling afunction but don't know how to redirect the client to a new window.

    This would be a great help to me if anybody can help.

    Thanks

    Paul

  2. #2
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code below changes the link in the main window.

    Code:
    <a  onClick="window.opener.location.href='my_page.html'">Back to main<a>
    You can also add the window.close(); line behind that, so that clicking the link will redirect the visitor and close the pop-up at the same time.

  3. #3
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well this is a javascript question.

    when calling the the popup window, with

    window.open('url','window_name','attributes')

    just call it via a variable

    like this

    var x;

    x = window.open('url','window_name','attributes');

    now all you have to do to close or modify that attribute is by doing this

    x.close();

    or you can add further functionality by passing commands to the popup like this; so it would be like your using the current window to add javascript

    x.document.write('Hi pahayes');
    x.document.body.style.backgroundColor='gray';
    x.document.body.style.color='white';

    well to redirect

    x.location.href='';

    replace will overwrite the previous history in the window so you cannot use the back button

    x.location.replace='';
    Last edited by Andrew-J2000; May 12, 2002 at 07:39.

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2001
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I`m lost

    Thanxs for the replies. But i don't it solves the problem. I want it so that when you execute a form by clicking for example "continue", it closes that current window (popup) and redirects the person to a fullscreen window.

    code:
    <script language="javascript">
    function closewindow()
    {window.close('shoplogin.asp','shoplogin','fullscreen=yes');}
    </script>

    <form name=form1 method=Post action=closewindow()
    <input type=submit name=action value=continue>
    </form>

    I would greatly appreciate your help again.

    Paul

  5. #5
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this will do it

    PHP Code:
    <html>
    <
    head>
    <
    title>close win</title>


    <
    script type="text/javascript">

      function 
    closewin()
      {
        
    window.close();
        
    window.open('shoplogin.asp','shoplogin','fullscreen=yes');
      }

    </script> 

    </head>

    <body>

    <form name="form1" method="Post" onsubmit="closewin()">
      <input type="submit" name="action" value="continue"> 
    </form> 

    </body>
    </html> 

  6. #6
    SitePoint Enthusiast
    Join Date
    Oct 2001
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    it works!

    workz perfectly thanxs


Bookmarks

Posting Permissions

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