Link to home
Start Free TrialLog in
Avatar of suran78
suran78

asked on

Close browser window

Experts,

I have a ASP submission form.  After user submits it, i want the ASP code to close the submission form after 1 min autmatically.  Please give me the code in asp/vbscript to close the submission window automatically.

Thanks.
suran
Avatar of Joachim Carrein
Joachim Carrein
Flag of Belgium image

you'll need to do this with javascript. but then the user still gets a message (you want to close this window?)
Avatar of suran78
suran78

ASKER

Yes, that will work.  Please provide the code.
Thanks.
response.Write "<script language=javascript>window.close();</script>"
you can try this easy in your browser, in the address bar type javascript:window.close();
and press enter, this is what the users will get then
Avatar of suran78

ASKER

Shoudl this be pasted after submission button?  Which is the best location?
Avatar of suran78

ASKER

OK, but I want the window to close automatically after 1 min, if the user forget to close it after submitting the form.  Is there anyway to close the browser automatically?  And yes when the code behind closes it automatically after 1 min, it can ask the question "do you want to close?"

Add the code below to your page.

<SCRIPT>
function CloseWin()
{
window.close()
}
set Timeout("CloseWin()", 60000)
</SCRIPT>
Avatar of suran78

ASKER

It's not closing, I tried it:

<script Language="JAVAScript">
  function CloseWin()
{
window.close()
}
set Timeout("CloseWin()", 60000)

</script>
Avatar of suran78

ASKER

getting error "expected ;"
on line -  set Timeout("CloseWin()", 60000)
setTimeout is one word not two...
Sorry, my bad.
Avatar of suran78

ASKER

It worked.  Thanks.
But it does not repeat the question is the user click no.  Can it keep asking until the window is closed?
ASKER CERTIFIED SOLUTION
Avatar of R_Harrison
R_Harrison
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial