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 1004353 of Document.onselectionchange

  • Revision slug: Web/API/Document/onselectionchange
  • Revision title: Document.onselectionchange
  • Revision id: 1004353
  • Created:
  • Creator: Brettz9
  • Is current revision? Yes
  • Comment

Revision Content

{{ApiRef('DOM')}}{{SeeCompatTable}}

The Document.onselectionchange property represents the event handler that is called when a {{event("selectionchange")}} event reaches this object.

Syntax

obj.selectionchange = function;
  • function is the name of a user-defined function, without the () suffix or any parameters, or an anonymous function declaration.

Example

document.onselectionchange = function() { console.log("Selection changed!"); }; 

Specifications

Specification Status Comment
{{SpecName('Selection API','','Document.onselectionchange')}} {{Spec2('Selection API')}} Initial definition.

Browser compatibility

{{CompatibilityTable}}

Feature Firefox (Gecko) Chrome Internet Explorer Opera Safari
Basic support {{CompatGeckoDesktop(45)}}[1] {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
Feature Firefox Mobile (Gecko) Android IE Mobile Opera Mobile Safari Mobile
onselectionchange {{CompatGeckoMobile(45)}}[1] {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}

[1] This is implemented behind the dom.select_events.enabled preference, that default to false, except on Nightly.

See also

  • {{event("selectionchange")}}
  • {{domxref("GlobalEventHandlers.onselectstart")}} and {{event('selectstart')}}.

Revision Source

<div>{{ApiRef('DOM')}}{{SeeCompatTable}}</div>

<p>The <code><strong>Document.onselectionchange</strong></code> property represents the event handler that is called when a {{event("selectionchange")}} event reaches this object.</p>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">
<em>obj</em>.selectionchange = <em>function</em>;
</pre>

<ul>
 <li><code>function</code> is the name of a user-defined function, without the () suffix or any parameters, or an anonymous function declaration.</li>
</ul>

<h2 id="Example">Example</h2>

<pre class="brush: html">
document.onselectionchange = function() { console.log("Selection changed!"); }; 
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="spectable standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('Selection API','','Document.onselectionchange')}}</td>
   <td>{{Spec2('Selection API')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Firefox (Gecko)</th>
   <th>Chrome</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatGeckoDesktop(45)}}<sup>[1]</sup></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>Android</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td><code>onselectionchange</code></td>
   <td>{{CompatGeckoMobile(45)}}<sup>[1]</sup></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] This is implemented behind the <code>dom.select_events.enabled</code> preference, that default to <code>false</code>, except on Nightly.</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{event("selectionchange")}}</li>
 <li>{{domxref("GlobalEventHandlers.onselectstart")}} and {{event('selectstart')}}.</li>
</ul>
Revert to this revision