JavaScript Confusion - Closing Page

  • Thread starter Thread starter - Steve -
  • Start date Start date
S

- Steve -

Shouldn't this work, causing the browser to close once
progress.Percentage reaches 100?

Page_Load
{
UpdateProgress();
}

UpdateProgress()
{
if(progress.Percentage < 100)
Page.Response.Write("Meta HTTP-EQUIV=Refresh CONTENT=3>");

else
Page.RegisterStartupScript("OnLoad",
"<script language=javascript>" +
"windows.close()" +
"</script>");
}
 
Nope. There is no JavaScript object called "windows". There IS an object
called "window." In addition, unless the page was opened by another Browser
instance, calling "window.close()" will cause a warning to pop up, allowing
the user to decide whether or not to close the window. If you want to
suppress that, you need to set the opener property of the window to self
first. Example:

<script type="text/javascript"><!--
window.opener = self;
window.close();
// --></script>

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top