Entry
Why does referencing a dynamically generated function in IE fail?
Aug 22nd, 2001 13:17
M Flaming, Jean-Bernard Valentaten,
Could you show us some code??
Yes:
I have an IFRAME which generates a new DIV element in its parent
document, and then writes some javascript into the new DIV. The code
(in the IFRAME) looks like:
function BuildNew() {
var tpane = '<DIV style="position: absolute; left: 100px; top: 200px ';
tpane += 'background-color: blue"> ';
tpane += '<h1>test layer</h1> ';
tpane += '<script language=javascript> ';
tpane += 'function TestMe() { alert( "foo" ); } <\/script> ';
tpane += '<form>';
tpane += '<input type=button name=test value=test onClick=TestMe();>'
tpane += '</form>';
tpane += '</DIV>';
self.parent.document.body.insertAdjacentHTML( 'beforeEnd', tpane );
}
-- I've tried a number of variations on this, and in all of them when I
try to call the dynamically generated TestMe() function I get an IE
error: Error: Object expected, line 1 character 1
Any thoughts on how to get around this would be greatly appreciated!