Forum Moderators: open

Message Too Old, No Replies

Closing a window on a submit button

         

andrewsmd

8:20 pm on Apr 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a php page that opens a new window on a link click. Here is the link
<A HREF="javascript:void(0)" onclick="window.open('addLink.php','Add','width=800,height=600,left=20,top=100,screenX=10,screenY=100')">Add</a>

Now on the addLink.php I have a submit button
<input type = "submit" name = "addSubmit" value = "Add Notes" onclick="setTimeout('window.close()',3000);">
What I want, is when the user clicks that submit button,
to wait for 3 seconds and then close. What is wrong with what I have there. Keep in mind php executes on that submit click. Thanks,

whoisgregg

10:00 pm on Apr 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Basically what's happening is the old page is already gone before the setTimeout fires. You can either have the PHP script echo a similar setTimeout statement when it has been posted to or, if you are worried about the submit taking longer than 3 seconds, have the <form> target a hidden iframe and your onclick should then work.

If you would like some sample code, have questions, or run into trouble, just post back and we'll do our best to help. :)

andrewsmd

10:24 pm on Apr 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nope that did it, I just echoed it after the fact with PHP. You should take a look at my other post on this forum if you have a second JavaScript PopUp. If not, that's ok. Thanks for your help :)

whoisgregg

2:50 am on Apr 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Glad to help! I actually did post to the other thread as well. :)