Dynamically changing html content of an IFRAME

J

Jeremy

Hi,
I am attempting to load an ad Banner to coincide with a piece of video
pre-roll. The following function is called which is supposed to create
an empty IFRAME. Once this IFRAME object is created javaScript should
then be able to open and write to the IFRAME. The following code seems
to work perfectly in I.E. however in Firefox doesn't want to work. If
anyone can help it would be greatly appreciated.

Thanks
Jeremy

JavaScript Source:

function FLA_HandleEmbedBanner(embedBanner)
{

var bannerHTML = embedBanner

var adFrame = document.createElement("IFRAME");
adFrame.setAttribute("src", "about:blank");
adFrame.setAttribute("frameborder", 0);
adFrame.style.width = 300+"px";
adFrame.style.height = 250+"px";
adFrame.id = "bannerIFrame"
adFrame.frameBorder = 0;
adFrame.scrollable = "no";

document.body.appendChild(adFrame);

adFrame.className = "bannerWindow"

document.frames["bannerIFrame"].document.open();

document.frames["bannerIFrame"].document.write("<html><body style =
'background-color:#000000;padding:0px;overflow:hidden;margin:0'>"+bannerHTML+"</body></html>");
document.frames["bannerIFrame"].document.close();

}

function destroyEmbededBanner()
{
document.getElementById("bannerIFrame").style.visibility =
"hidden"
}

</script>
 
M

Martin Honnen

Jeremy said:
var adFrame = document.createElement("IFRAME");

adFrame.id = "bannerIFrame"

Use name and id
adFrame.name = adFrame.id = "bannerIFrame";

document.body.appendChild(adFrame);
document.frames["bannerIFrame"].document.open();

then cross browser the frame should be found in window.frames
var iframeWin = window.frames["bannerIframe"], iframeDoc =
iframeWin.document;
iframeDoc.open();
iframeDoc.write(...);
iframeDoc.close();
document.frames["bannerIFrame"].document.write("<html><body style =
'background-color:#000000;padding:0px;overflow:hidden;margin:0'>"+bannerHTML+"</body></html>");
document.frames["bannerIFrame"].document.close();

}

function destroyEmbededBanner()
{
document.getElementById("bannerIFrame").style.visibility =
"hidden"
}

</script>
 

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,982
Messages
2,570,189
Members
46,734
Latest member
manin

Latest Threads

Top