Capture when disabled property is changed (IE8 compatible) - javascript

Is there any simple way to capture an event when an element disabled property (or other css properties) is changed? I know there is MutationObservers, but it seems is not supported by IE8-IE9. I need to use a plugin?
Actual MutationObservers compatibility:
Chrome: 18-16
Firefox: 14
IE: 11
Opera: 15
Fafari 6

According to the DOM L3 Event specification, MutationOberservers were introduced with DOM4 Events to replace MutationEvents originally defined by DOM L3 events. (It appears there were inconsistences in the way different browsers implemented support.)
The IE Compatibility Cookbook has more details on this change, including migration details.
So you might be able to use MutationEvents for IE9 and IE10; however, they were not supported in IE8. Caniuse suggests the HTML Web Components polyfill as a possible alternative.
Hope this helps...
-- Lance

Related

Why wont IE fire on paste event?

I need help figuring out why Internet Explorer won't fire my 'paste' event.
I'm using IE 11. Here is my code:
$(document).on('paste', '.pasteTarget', handlePaste);
When trying this in IE, the function never gets called. It works in chrome.
Different browsers treat onpaste differently, or not at all. For IE 11, the latter seems to be the case.
From MDN:
Non-Standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
Source
Edit: As pointed out in the comments, IE 11 does indeed support onpaste to some extent. However, as this is a non-standard feature, you should be careful about using it in production.
You could use beforepaste event instead and access clipboardData from window, not from the event.
But, indeed as pointed out already, Clipboard API doesn't seem to be supported in IE: https://developer.microsoft.com/en-us/microsoft-edge/platform/status/clipboardapi/

Adapting IE8 to IE11

I have this code:
container = document.getElementById("menuContainer");
and later on:
container.document.open("text/html");
container.document.writeln(content);
container.document.close();
In IE8 works but in IE11 warns me:
What can I do?
The recommended standard reference from the node to a document has been node.ownerDocument since DOM Level 2. According to MDN: ownerDocument is supported since IE6. In IEs node.document was also supported until IE10.
The fix for your code would hence be:
container.ownerDocument.open(...);
document.write was used in the example only to demonstrate the output, not as real code, hence I'm not handling its use in this answer.

Firefox doesn't support onfocusout

I am using onfocusout as an html attribute and some javascript code inside it. Nevertheless, the code works fine in Chrome and browsers powered by webkit engines but it doesn't work in Firefox, I haven't tested other browsers yet.
Is there any alternative for 'onfocusout' attribute which is supported at least by firefox and chrome?
Can you use onblur?
Not sure what elements you are targeting but blur may work for you.
If that doesn't work for you then you may want to include a framework like jQuery which will help you with such cross browser issues.
http://api.jquery.com/focusout/
I know this question is from 2011, just want to let everyone know that FireFox support for this attribute is now available since March 6th, 2017: https://caniuse.com/#search=focusout

Does Opera capture events by default and what is the correct behaviour?

I had some event code which failed in Opera and I have stripped it down to this small testcase.
Basically the problem is that the event handler doesn't run in Opera if the third parameter of addEventListener is not set. The value in the testcase increments in both Firefox and Chrome when the "useCapture not set"-button is clicked, but not in Opera.
This (old) article indicates that Opera is different than webkit & gecko browsers:
http://my.opera.com/hallvors/blog/2006/10/12/2006-10-12-event-capture-explained. I'm not sure what to make out of it though. MDN says useCapture should default to false.
is the default true in Opera, is the parameter simply not optional, or what am I missing? What is the correct behaviour?
If in doubt, refer to the spec. The original and still current spec is W3C's DOM Level 2 Events. Looking at the ECMASCript binding page, it looks as though the useCapture parameter is required, since there is no mention of it being optional.
DOM Level 3 Events explicitly mentions useCapture as being optional, although I don't think this draft spec has ever reached widespread adoption in browsers.
The relevant MDN page also has a note on this:
Note: useCapture became optional only in more recent versions of the
major browsers; for example, it was not optional prior to Firefox 6.
You should provide that parameter for broadest compatibility.
Bottom line: it's safest to always pass in all three parameters, and Opera is well within its rights to insist on it.
The disparity compared with DOM Level 3 Events is a bug, and will be fixed in Opera 12.

Are IE9 events fully DOM Level 2 Compliant?

Can anyone tell me if IE9 is fully DOM level 2 compliant? For example, that it now supports .stopPropagation()?
Yes, events in IE 9 are fully DOM 2 compliant and support stopPropagation() and preventDefault() methods.
Here's a test case that proves it: http://jsfiddle.net/pke26/

Categories

Resources