www.webdeveloper.com
Results 1 to 2 of 2

Thread: Closing a child page from the parent onsubmit

  1. #1
    Join Date
    Mar 2012
    Posts
    4

    Question Closing a child page from the parent onsubmit

    I am a bit of a noob to Javascript and have been creating a website for a client.

    I have designed a form in php which opens as a popup using Javascript.

    I was wondering if there was a way to close the window but with a delay after the form has submitted... I have been searching for a few days but I'm not too sure where to search... I have been playing about with window.close(); and obviously setTimeout("self.close()", 1000)

    But when I have the page open it is a child popup that has a php form on it and I want it to display the message saying thanks for the contact blah blah blah... although if I use onSubmit it ignores the on submit as it navigates to another page showing the confirmation of submission... I want it to automatically close after a few seconds and refresh the parent window.

  2. #2
    Join Date
    Feb 2010
    Location
    Amsterdam
    Posts
    174
    you can write something in the page after it is submitted

    something like this in asp.net

    Code:
    if(IspostBack)
    {
     Write("<script type="text/javascript">SetTimeout(function(){
    // opener is a reference to the page which opened the popup
     opener.document.getElementById('theIdOfTheLabelOnOpenerPage').innerHTML = 'thanks for posting the popup is going to be closed';
     self.close();
    }, 1000);</script>"
    }
    so the above javascript only gets written to the page if you have a successful post (which you determine server side)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles