...

View Full Version : Clearing Iframes



amccarthy91
07-12-2012, 03:32 PM
Hi guys,

I'm attempting to create a button that will allow a user to "clear" the contents of an iframe. What it actually should do is just set the iframe back to a default page. For some reason, though, I cannot figure out how to get it to work.

Here's the code:


<script type="text/javascript">
function clear()
{
document.getElementById('iframe2').src = 'defaultiframe.html';
}
</script>


function changeLeft(leftcolname){
deleteMenu()
if(leftcolname=='Single')
{
var oldHTML = document.getElementById('leftcol').innerHTML;
var newHTML = oldHTML +
"<p style='font-size:14px'><b>Tests</b></p>"+
"<a href='testpage.html' target='iframe2'>Test Page</a><br /><br /> "
+"<button onClick='clear()'>Clear Text</button>"


<iframe align="middle" id="iframe2" name= "iframe2" src="defaultiframe.html" height="1000" width="1000" frameborder="0" marginheight="0" marginwidth="0"></iframe>

Basically, I have a menu that uses the changeLeft() function to dynamically change the left navigation based on what tab the main menu is on. I want to place the clear button on the left hand navigation. Any thoughts?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum