diff options
Diffstat (limited to 'files/it/web/api/window/close/index.html')
| -rw-r--r-- | files/it/web/api/window/close/index.html | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/files/it/web/api/window/close/index.html b/files/it/web/api/window/close/index.html new file mode 100644 index 0000000000..de07d87f7b --- /dev/null +++ b/files/it/web/api/window/close/index.html @@ -0,0 +1,72 @@ +--- +title: Window.close() +slug: Web/API/Window/close +translation_of: Web/API/Window/close +--- +<p>{{APIRef}}</p> + +<p>Il metodo <code><strong>Window.close()</strong></code> chiude la finestra corrente, oppure quella sulla quale è invocato.</p> + +<p>Questo metodo può essere invocato solo su finestre che sono state aperte da uno script utilizzando il metodo {{domxref("window.open()")}}. Se la finestra non è stata aperta mediante script, nella Console JavaScript apparirà il seguente errore: <code>Scripts may not close windows that were not opened by script.</code></p> + +<h2 id="Syntax" name="Syntax">Sintassi</h2> + +<pre class="syntaxbox">window.close();</pre> + +<h2 id="Examples" name="Examples">Esempi</h2> + +<h3 id="Closing_a_window_opened_with_window.open.28.29" name="Closing_a_window_opened_with_window.open.28.29">Chiudere una finestra aperta mediante <code>window.open()</code></h3> + +<p>Questo esempio mostra come chiudere una finestra aperta da uno script mediante l'invocazione di {{domxref("window.open()")}}.</p> + +<pre><script> +//Variabile globale in cui si memorizza un riferimento alla finestra aperta +var openedWindow; + +function openWindow() +{ + openedWindow = window.open('moreinfo.htm'); +} + +function closeOpenedWindow() +{ + openedWindow.close(); +} +</script> +</pre> + +<h3 id="Closing_the_current_window" name="Closing_the_current_window">Chiudere la finestra corrente</h3> + +<p>Quando si invoca direttamente il metodo <code>close() sull'oggetto<font face="Open Sans, Arial, sans-serif"> </font></code><code>window</code>, piuttosto che invocare <code>close()</code> su una <strong>istanza</strong> di <code>window</code>, il browser chiuderà la finestra in primo piano, indipendentemente dal fatto che uno script abbia creato quella finestra oppure no. (Firefox 35.0.1: gli script non possono chiudere una finestra che non hanno aperto)</p> + +<pre><script> +function closeCurrentWindow() +{ + window.close(); +} +</script> +</pre> + +<h2 id="Specification" name="Specification">Specifica</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specifica</th> + <th scope="col">Stato</th> + <th scope="col">Commenti</th> + </tr> + <tr> + <td>{{SpecName('HTML WHATWG', '#dom-window-close', 'window.close()')}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td> </td> + </tr> + </tbody> +</table> + + +<h2 id="Browser_compatibility">Browser compatibility</h2> + + + +<p>{{Compat("api.Window.close")}}</p> |
