PDA

View Full Version : Closing window automatically in ASP function


njk966
03-15-2003, 01:18 PM
I have an ASP page that displays info, if user decides to save info via submit button it then submits page data back to itself and returns a var back to the calling page.

Problem: Closing window automatically after ASP code processed

My Go At It:

<FORM ID="Form1" method="post" action="SaveInfo.asp;window.close();self.opener.ReturnFunction("SomeVar");>

<% Sub DisplayInfo()
<input type=submit value=Save>
%>

<% Sub SaveInfo()
<input type=submit value=Save>
%>

cheesebagpipe
03-15-2003, 11:10 PM
Oops. You can only call JS from a url-expecting property (form action, link href, e.g.) with the javascript: url. Also: not a good idea to close a window with script in it still left to run (JS suicide).

<FORM ID="Form1" method="post" action="SaveInfo.asp" onsubmit="if(opener&&!opener.closed)opener.ReturnFunction("SomeVar");self.close()">

njk966
03-17-2003, 12:41 AM
Thanks for your response. Sorry about the mistakes. I pasted example code and hit the submit button before reviewing. You're absolutely right though. Many thanks.