Javascript Popups: Submit Form, Show & ldquo; wait & rdquo; screen for 5 seconds then the automatic closing


I have a popup that requires the user to fill out a form. Once the form is submitted, I need to take them to a "Waiting" screen inside that same popup while their info is checked. This is a prototype, so it only needs a delay of about 5 seconds as nothing is actually being checked. Then I'd like to close the popup automatically after that delay, instead of using window.close(); attached to a button.

Here's the script I'm using: (edited to remove inline js)

function centeredPopup(url,winName,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
popupWindow =,winName,settings)

    $(this).click(centeredPopup("popup.php","Popup Name","680","560"));

        setTimeout(function() {
        }, 5000);

How I'm firing the popups:

<a class="button" id="linkPopup">Popup Link</a>

Using my code above, the form just submits to the waiting screen but doesn't close it out after the specified duration, so I'm assuming there's something wrong with my syntax or structure.

Expected Behavior:

here's a plunker:

first thing's first, consider this answer on why you shouldn't use inline javascript.

in order to open a popup window you could use:;, strWindowName[, strWindowFeatures]);

after the popup opens, you can close it with

you'll need to set a timer, that'll wait 5 seconds and then close the popup

window.setTimeout(func, delay, [param1, param2, ...]);