Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 718475 of WindowEventHandlers.onunload

  • Revision slug: Web/API/WindowEventHandlers.onunload
  • Revision title: WindowEventHandlers.onunload
  • Revision id: 718475
  • Created:
  • Creator: Taken
  • Is current revision? No
  • Comment

Revision Content

{{ APIRef() }}

Summary

The unload event is raised when the window is unloading its content and resources. The resources removal is processed after the unload event occurs.

Syntax

window.onunload = funcRef;
  • funcRef is a reference to a function.

Notes

Using this event handler in your page prevents Firefox 1.5 from caching the page in the in-memory bfcache. See Using Firefox 1.5 caching for details.

Browsers equipped with pop-up window blockers will ignore all window.open() method calls in onunload event handler functions.

You can and should handle this event through {{domxref("EventTarget.addEventListener","window.addEventListener()")}} and the {{event("unload")}} event. More documentation is available there.

Specifications

Specification Status Comment
{{SpecName('HTML WHATWG', '#windoweventhandlers', 'GlobalEventHandlers')}} {{Spec2('HTML WHATWG')}}
{{SpecName('HTML5.1', '#windoweventhandlers', 'GlobalEventHandlers')}} {{Spec2('HTML5.1')}}
{{SpecName("HTML5 W3C", "#windoweventhandlers", "GlobalEventHandlers")}} {{Spec2('HTML5 W3C')}}

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{CompatVersionUnknown()}} {{CompatVersionUnknown()}} {{CompatVersionUnknown()}} {{CompatVersionUnknown()}} {{CompatVersionUnknown()}}
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{CompatVersionUnknown()}} {{CompatVersionUnknown()}} {{CompatVersionUnknown()}} {{CompatVersionUnknown()}} {{CompatVersionUnknown()}}

Revision Source

<p>{{ APIRef() }}</p>
<h2 id="Summary">Summary</h2>
<p>The <code>unload</code> event is raised when the window is unloading its content and resources. The resources removal is processed <em>after</em> the <code>unload</code> event occurs.</p>
<h2 id="Syntax">Syntax</h2>
<pre class="eval">
window.onunload = <em>funcRef</em>;
</pre>
<ul>
 <li><code>funcRef</code> is a reference to a function.</li>
</ul>
<h2 id="Notes">Notes</h2>
<p>Using this event handler in your page prevents Firefox 1.5 from caching the page in the in-memory bfcache. See <a href="/En/Using_Firefox_1.5_caching" title="En/Using_Firefox_1.5_caching">Using Firefox 1.5 caching</a> for details.</p>
<p>Browsers equipped with pop-up window blockers will ignore all <code>window.open()</code> method calls in <code>onunload</code> event handler functions.</p>
<p>You <em>can</em> and <em>should</em> handle this event through {{domxref("EventTarget.addEventListener","window.addEventListener()")}} and the {{event("unload")}} event. More documentation is available there.</p>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('HTML WHATWG', '#windoweventhandlers', 'GlobalEventHandlers')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td></td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5.1', '#windoweventhandlers', 'GlobalEventHandlers')}}</td>
   <td>{{Spec2('HTML5.1')}}</td>
   <td></td>
  </tr>
  <tr>
   <td>{{SpecName("HTML5 W3C", "#windoweventhandlers", "GlobalEventHandlers")}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td></td>
  </tr>
 </tbody>
</table>
<h3 id="Browser_compatibility">Browser compatibility</h3>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Chrome</th>
    <th>Firefox (Gecko)</th>
    <th>Internet Explorer</th>
    <th>Opera</th>
    <th>Safari (WebKit)</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{CompatVersionUnknown()}}</td>
    <td>{{CompatVersionUnknown()}}</td>
    <td>{{CompatVersionUnknown()}}</td>
    <td>{{CompatVersionUnknown()}}</td>
    <td>{{CompatVersionUnknown()}}</td>
   </tr>
  </tbody>
 </table>
</div>
<div id="compat-mobile">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Android</th>
    <th>Firefox Mobile (Gecko)</th>
    <th>IE&nbsp;Phone</th>
    <th>Opera Mobile</th>
    <th>Safari Mobile</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{CompatVersionUnknown()}}</td>
    <td>{{CompatVersionUnknown()}}</td>
    <td>{{CompatVersionUnknown()}}</td>
    <td>{{CompatVersionUnknown()}}</td>
    <td>{{CompatVersionUnknown()}}</td>
   </tr>
  </tbody>
 </table>
</div>
Revert to this revision