MediaQueryList.removeListener()
El método removeListener()
de la interfaz MediaQueryList
elimina un escucha de MediaQueryListener
.
Esto es básicamente un alias para EventTarget.removeEventListener()
, para propósitos de compatibilidad con versiones anteriores: en los navegadores antiguos puede usar removeEventListener()
.
Sintaxis
MediaQueryList.removeListener(func)
Parametros
- func
- Una función o referencia de función que representa la función de devolución de llamada que desea eliminar. En la implementación original, la devolución de llamada era un objeto
MediaQueryListListener
no estándar. En la nueva implementación se utiliza el mecanismo de eventos estándar y la devolución de llamada es una función estándar.
Return value
Void.
Ejemplos
var mql = window.matchMedia('(max-width: 600px)');
function screenTest(e) {
if (e.matches) {
/* the viewport is 600 pixels wide or less */
para.textContent = 'This is a narrow screen — less than 600px wide.';
document.body.style.backgroundColor = 'red';
} else {
/* the viewport is more than than 600 pixels wide */
para.textContent = 'This is a wide screen — more than 600px wide.';
document.body.style.backgroundColor = 'blue';
}
}
mql.addListener(screenTest);
// Later on, when it is no longer needed
mql.removeListener(screenTest);
Especificaciones
Especificaciones | Estado | Comentario |
---|---|---|
CSS Object Model (CSSOM) View Module La definición de 'removeListener' en esta especificación. |
Working Draft | Initial definition |
Compatibilidad del navegador
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help!
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 9 | (Yes) | 6.0 (6.0) | 10 | 12.1 | 5 |
New version spec update | (Yes) | ? | 55 (55) | Sin soporte | (Yes) | ? |
Feature | Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|
Basic support | ? | (Yes) | ? | ? | ? | ? | ? |
New version spec update | Sin soporte | ? | 55.0 (55) | Sin soporte | (Yes) | ? | (Yes) |