...

View Full Version : Hide an <iframe> on click.



Basscyst
10-19-2003, 06:50 PM
Seems this is pretty straight forward but I can't get it to work. I just want the iframe to stop displaying on click. Am I missing somthing here?

<html>
<head>
<script language="javascript">
function hideFrame()
{
pane.style.display="none";
}
</script>
</head>
<body>
<iframe src="" id="pane"></iframe>
<input type="button" onclick="hideFrame()">
</body>
</html>

fredmv
10-19-2003, 06:52 PM
Try this:

document.getElementById("pane").style.display="none";

Basscyst
10-19-2003, 07:03 PM
That did the trick. Thanks alot! I was thinking I couldn't use getElementById on an inline frame but now that I think about it, it's the just the document of the iframe that won't work on (if i wanted to document.write to it). It's strange though in my actual code I have 2 frames in this function I am hiding one and replacing the contents of another. I don't need the getElemenbyId for the frame I am replacing the contents of, but for the one I want hidden I do. Why is that? The function looks just like this now.

function seeBase()
{
disp1.location.replace(document.getElementById('dbPath').value);
document.getElementById('disp2').style.display="none";
}

fredmv
10-19-2003, 07:08 PM
Could you please post the rest of the HTML code? It may be because you're referring to it using it's name attribute as opposed to it's id attribute.

Basscyst
10-19-2003, 07:14 PM
Sure thing. Here is the code: Thanks for the help.
Oh you just want the HTML sorry.

<--<removed JS>-->

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<body>
<center>
<h2>Overtime Database Utility</h2>
<form name="shifts">
DB:<input type="file" id="dbPath">
CSV:<input type="file" id="otPath" name="it">
<input type="button" value="Start" onclick="previewChanges()">
<br>
<iframe src="" id="disp1" height=400 width=315></iframe>
<iframe src="" id="disp2" height=400 width=315></iframe>
<br>
<input type="button" onclick="makeNew();" value="Update Database">

<input type="button" onclick="purgeData();" value="Purge Files">
<input type="button" onclick="seeBase()" value="View Database">
<input type="button" onclick="window.location.reload()" Value="Finish">
</form>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum