cyshaw
04-12-2007, 04:52 PM
I'm trying to work with IFrames with JavaScript and DOM. I have a HTML page with image properties on it and one IFrame with the image in it. When the user changes the properties on the side the image refreshes to show a preview. The problem I'm having is adding DOM elements to the IFrame.
I'm trying to add a <div> to the IFrame window.
I'm using:
var curDiv = window.frames['imgFrame'].document.getElementById("currentDiv");
alert(curDiv);
var newDiv = window.frames['imgFrame'].document.createElement("newDiv");
curDiv.appendChild(newDiv);
It works for IE (the alert returns the object); however, I can't get the object using Firefox 1.5. I get the JS Error curDiv does not have any properties. Why isn't window.frames working with Firefox?
Please help.
I'm trying to add a <div> to the IFrame window.
I'm using:
var curDiv = window.frames['imgFrame'].document.getElementById("currentDiv");
alert(curDiv);
var newDiv = window.frames['imgFrame'].document.createElement("newDiv");
curDiv.appendChild(newDiv);
It works for IE (the alert returns the object); however, I can't get the object using Firefox 1.5. I get the JS Error curDiv does not have any properties. Why isn't window.frames working with Firefox?
Please help.