I have created an iframe on the fly and attached an event listener like this:
// set content to load when document is ready
if (window.addEventListener) {
editframe.addEventListener("load", setContent, false);
}
else if (window.attachEvent) {
editframe.attachEvent("******", setContent);
}
And here is the listener:
function setContent() {
var frame = frames['edit_frame'];
frame.document.getElementById('container').innerHTML=content;
// set iframe height
scaleFrame('edit_frame');
}
And everything works fine. But why doesn't this work?
function setContent() {
var frame = this;
frame.document.getElementById('container').innerHTML=content;
// set iframe height
scaleFrame('edit_frame');
}
Notice the use of 'this' to reference the calling object - doing that produces the error 'frame.document has no properties'. I know the iframe is being referenced correctly by 'this' because I can do 'alert(this.id)' and get the correct response...
Thanks for any help.
/Edit: the ****** up there is 'o n l o a d' ... apparently they censor that.
// set content to load when document is ready
if (window.addEventListener) {
editframe.addEventListener("load", setContent, false);
}
else if (window.attachEvent) {
editframe.attachEvent("******", setContent);
}
And here is the listener:
function setContent() {
var frame = frames['edit_frame'];
frame.document.getElementById('container').innerHTML=content;
// set iframe height
scaleFrame('edit_frame');
}
And everything works fine. But why doesn't this work?
function setContent() {
var frame = this;
frame.document.getElementById('container').innerHTML=content;
// set iframe height
scaleFrame('edit_frame');
}
Notice the use of 'this' to reference the calling object - doing that produces the error 'frame.document has no properties'. I know the iframe is being referenced correctly by 'this' because I can do 'alert(this.id)' and get the correct response...
Thanks for any help.
/Edit: the ****** up there is 'o n l o a d' ... apparently they censor that.