PDA

View Full Version : clearing dynamic iframe content


arcsecond
03-29-2005, 02:45 PM
I have an iframe. When I click on a link I want to pass image url and text information to a javascript function and build an html file to put in this iframe with said information. I can get stuff into the iframe but I don't seem to be able to clear previous content out. Content just concatenates.

All the info I've found in my web searches suggests that I use the document.clear() method. But this doesn't seem to work. One of the pages I found said the clear method was deprecated. I've also tried just replacing the entire iframe with a blank.html and then writing my code into it all over again but this doesn't work properly either. It requires a double click. One to clear things out and one to put new content into. Which makes no sense whatsoever.

################
Javascript Code So Far:
################

function imageDisp(thisImage, thisText) {

window.frames['testIframe'].window.document.clear;
window.frames['testIframe'].location = "blank.html";

window.frames['testIframe'].window.document.open;
window.frames['testIframe'].window.document.write('<html><head><title>Image</title></head>');
window.frames['testIframe'].window.document.write('<body bgcolor="#FFCC66" onLoad="window.focus()"><center><img src=');
window.frames['testIframe'].window.document.write(thisImage);
window.frames['testIframe'].window.document.write('><p><font size=1>');
window.frames['testIframe'].window.document.write(thisText);
window.frames['testIframe'].window.document.write('<p></font></center>');
window.frames['testIframe'].window.document.write('</body></html>');
window.frames['testIframe'].window.document.close;

}//end function

################
HTML Code So Far:
################

<a href="javascript:imageDisp('http://www.arcsecond.net/thumbs/jeepWThum.jpg', 'Jeep Text')">Test 1</a><br>
<a href="javascript:imageDisp('http://www.arcsecond.net/thumbs/faceSubThum.jpg', 'Sub Text')">Test 2</a><br>
<a href="blank.html" target="testIframe">Clear Frame</a><br>

<p>
<iframe id="testIframe" name="testIframe" src="blank.html"></iframe>



Is there another method for clearing dynamic content? Thanks for any help.

-James
www.arcsecond.net
james_parks@hotmail.com