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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top