EN
Il contenuto non è disponibile nella lingua di destinazione, ma solo in inglese.

close method

Closes the app without prompting the user. To the user, it appears as though the app has crashed.

Syntax

var retval = window.close();

Parameters

This method has no parameters.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Standards information

There are no standards that apply here.

Remarks

When a function fired by an event on any object calls the close method, the window.close method is implied.


<script type="text/javascript">
  function myClose() {
    close();
  }
</script>
<body onclick="myClose();">
Click this page and window.close() is called.
</body>
 


When an event on any object calls the close method, the document.close method is implied.


<button onclick="close();">
Click this button and document.close() is called.
</button>

Using the close method in a Windows Store app using JavaScript

Invoking the window.close method on a Windows Store app using JavaScript closes the app without prompting the user.

It is against Windows Store policy to programmatically close your app. The only time an app should programmatically close is when there is an unrecoverable error, in which case the app should throw an unhandled exception or use the MSApp.terminateApp method.

In you use window.close, it appears as a crash to the user is logged as a crash in the developer’s telemetry data on the Windows Store dashboard.

See also

window

 

 

Mostra:
© 2014 Microsoft