Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Refresh the parent window and close the child window on clicking the button in child window

    • 0
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 291
    Comment on it

    How to refresh the parent window and close the child window on clicking the button in child window using JavaScript

    If you want to close your child window and refresh its parent window on click of a button, we can do that with the help of following code:

    HTML:

    <button type="button" onclick="closeWindow()">Click Me</button>
    

    JS:

    function closeWindow(){
      opener.location.reload(); 
      window.close(); 
    }
    

    In this, opener.location.reload will help you reload you parent window.
    And window.close is used to close the current window i.e. the child window.

    Hope this will help you.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: