Z
Z
zevgenay2017-09-10 12:58:08
Books
zevgenay, 2017-09-10 12:58:08

Why doesn't the 'paste' event work in IE?

The task as a whole: to insert a picture from the clipboard. The main problem that I have been sitting with for more than one hour is Internet Explorer, here is an example of code that does not work in IE... The insert event does not work, the solution did not work on google :(
Help, plzzzzzzz...

var el = document.getElementById('editor');

    el.addEventListener('paste', function (e) {
        console.log(123);
        var clipboard = e.clipboardData;

        if (clipboard && clipboard.types) {
            var types = clipboard.types;

            if (types.indexOf('public.url') > -1) {
                // Останавливаем действие по умолчанию, чтобы не вставлялась картинка с фейковым урлом (webkit-fake-url://416873AC...)
                e.preventDefault();

                // Вставляем картинку
                var img = new Image();
                img.src = clipboard.getData('public.url');

                el.appendChild(img);
            }
        }
    });

Answer the question

In order to leave comments, you need to log in

3 answer(s)
T
tsarevfs, 2019-05-22
@leakt

Like sensible people did. https://ru.coursera.org/learn/c-plus-plus-white
C++ has been actively changing, so fresh books are preferable. But this does not mean that everything that has been written before is completely outdated.
I can recommend Meyers "Effective C++". But this is after you master the basic syntax.

G
GavriKos, 2019-05-22
@GavriKos

I advise you to read the search results at least on the toaster.

M
Mikhail Osher, 2017-09-10
@miraage

https://developer.mozilla.org/en-US/docs/Web/Event...
And who said that this event is supported in IE?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question