Why wont IE fire on paste event? - javascript

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/

Related

Capture when disabled property is changed (IE8 compatible)

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

Detecting Event change in fullscreen mode Internet explorer

I am trying to write an event handler that detects whether a video player I have is in fullscreen or 'regular' mode.
I have tried using
document.addEventListener("fullscreenchange", myfunc, false);
but this doesn't work in IE, I have implemnted the same thing for firefox and chrome using webkitfullscreenchange and mozfullscreenchange event. Is there any other event I can use in IE for this? Or another way of doing this?
Any help would be appreciated. Thanks!
You have jQuery, so use it:
var screen_change_events = "webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange";
$(document).on(screen_change_events, function () {
});
(addEventListener isn't supported in versions earlier than IE 9 anyways)
At the same time, it doesn't look like full screen is supported in any version of IE:
http://caniuse.com/fullscreen
MDN Reference:
https://developer.mozilla.org/en-US/docs/DOM/Using_fullscreen_mode
Here's a possible hack around it:
onfullscreenchange DOM event
There is a jQuery plugin named jquery-fullscreen that will do exactly what you want. Until the Fullscreen-API standard has crystallized this is probably the best option.
You can also use the Modernizr fullscreen-api check and shim it if the browser doesn't support it by firing the event yourself (see this question for a detection method)

Does deleteCell cause a pseudo-leak?

According to this website calling removeChild() in JavaScript causes an Internet Explorer Specific leak called a pseudo-leak.
Sometimes Internet Explorer keeps items in memory after the page is done using them. Although these pseudo-leaks are freed after the user leaves the page, some web pages may be open for long periods of time. To avoid pseudo-leaks, do not use removeChild to remove elements. Instead, set the parent's innerHTML to ""
Does deleteCell() cause pseudo-leaks the same way that removeChild() does?
Edit: I was able to reproduce this error on IE8. Believe it or not, Microsoft claims to have fixed this problem in IE7.
I don't have the benefit of being able to look at IE's source code and confirm, but I imagine if it's anything like how Chrome implements deleteCell, it uses removeChild internally, which could trigger IE's pseudo leak. I know older versions of IE had this issue, but I'm not sure if the current versions do.
From chromium source:
void HTMLTableRowElement::deleteCell(int index, ExceptionCode& ec)
{
...
HTMLElement::removeChild(cell.get(), ec);
}

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

Override IE email auto-formatting in rich-text editor

Our site makes use of FreeTextBox, a web-based, rich-text editor. In IE, but in not Firefox, if a user types in something like:
someone#blah
IE automatically creates a mailto hyperlink. I have tested this with other text editors out there and the story is the same with all of them.
Can I override this browser behavior somehow from within my application?
This has to do with the MSHTML editor, which (I'm guessing all) Windows browsers use to instantiate rich text editors. There's a setting called IDM_AUTOURLDETECT_MODE that lets you decide if the autolinking will take place, and the default is true (other browsers apparently set it to false on instantiation, hence no autolinking in Firefox.)
Unfortunately, until recently Microsoft didn't have a mapping from the command ID to a command identifier string, so the function wasn't accessible via Javascript prior to IE9.
I just tried it out in IE9 and can confirm that, for that version and presumably all future ones, you can override the feature by calling
document.execCommand("AutoUrlDetect", false, false);
Note that it's IE9+ only, so you're still stuck for previous versions, and that you'll want to wait until the DOM is loaded before you call it and have some error handling around it, etc, etc.
There's a good summary of the original issue here, and a discussion of the fix in the minor change list here.

Categories

Resources