“Aplique o EventListener ao iframe” Respostas de código

Como adicionar ouvinte de eventos ao iframe

var iframe = document.getElementById('myIFrame');
iframe.contentWindow.body.addEventListener('mouseup', Handler);

function Handler() {
    alert('works');
}
Old Knight

Aplique o EventListener ao iframe

var iframe = document.getElementsByTagName('iframe')[0],
    iDoc = iframe.contentWindow     // sometimes glamorous naming of variable
        || iframe.contentDocument;  // makes your code working :)
if (iDoc.document) {
    iDoc = iDoc.document;
    iDoc.body.addEventListener('afterLayout', function(){
                        console.log('works');
                });
};
Stormy Shark

Respostas semelhantes a “Aplique o EventListener ao iframe”

Perguntas semelhantes a “Aplique o EventListener ao iframe”

Mais respostas relacionadas para “Aplique o EventListener ao iframe” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código