469,590 Members | 2,464 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,590 developers. It's quick & easy.

Dynamically changing html content of an IFRAME

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.visi bility =
"hidden"
}

</script>

Dec 11 '06 #1
1 1673
Jeremy wrote:
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.visi bility =
"hidden"
}

</script>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 11 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.