addEventListener to IFRAME

Q

Quarco

Next challenge.. :)

How to execute a function on 'load' of (dynamically created) iframe..
E.g: alert the title of loaded document....



Tried this:

var frms =
document.getElementById('container').getElementsByTagName('iframe');
for(var i=0; i<frms.length; i++) {
frms.addEventListener("load", function() {
alert(frms.contentWindow.content.title);}, false);
}

This doesn't work.... :-(

Next 'solution' only alerts initial loaded page title:

var iFrames =
top.document.getElementById('container').getElementsByTagName('iframe');
for(var i=0; i<iFrames.length; i++) {
(function(monkey) {
iFrames.addEventListener('load', function(e) {
alert(this.src);
}, false);
})(iFrames);
}


Hope someone can help me out :))))


Thanx in advance anyway..
Marco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top