Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Can iframe hide itself?
May 25, 2005, 4:30 pm
rate this thread
the user needs to edit some values in a database. Once the user had
completed the edit, or cancels the edit, I would like the IFRAME to become
invisible again. The reason for the iframe is that this ASP page contains a
rather large SQL query that we would avoid rerunning when the user edits
It's easy to make the frame visible as this code is included in the parent
document, but the code to hide the IFRAME again will be in the IFRAME
document. How can the child IFRAME hide itself? Or, in other words, how can
the child IFRAME reference the parent document to change it's style?
Re: Can iframe hide itself?
Hrm.. For some reason it doesn't seem to work...
Iframe from the parent page:
<iframe src="subEdit.asp" name="EditFrame" id="EditFrame"
... the error being "Parent.EditFrame.style is not an object"
*sigh* What am I doing wrong?
Re: Can iframe hide itself?
On Wed, 25 May 2005 16:30:24 +0000, Noozer wrote:
Don't know if this helps much, but I use iframes a lot to carry out behind
the scenes database queries. For example, if I have a select list which is
dependent on what the user types into other fields (like a database search
filter), I would like to perform the database query and refill the select
list without needing to refresh the entire page. Another example is when I
have users save data to the database. In this case, a page refresh is
expensive due to the complexity of the page, and so an iframe to perform a
behind-the-scenes database query (insert or update here) is perfect.
But in my case, I define the iframe as invisible, and I leave it
invisible. The iframe is defined with
<div style="visibility:hidden"><iframe src="ifrm.php" name="ifrm"
id="ifrm" scrolling="no" frameborder="0" width="0"
and simply calls a server side php file called ifrm.php when the iframe is
The iframe itself (defined in ifrm.php) is a simple document containing a
form and various hidden fields for data transfer. Here is part of it:
<form name="ifrmform" method="post"
action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="param1" value="">
<input type="hidden" name="param2" value="" > <input type="hidden"
name="param3" value="" > <input type="hidden" name="param4" value="" >
<input type="hidden" name="param5" value="" > <input type="hidden"
name="param6" value="" > <input type="hidden" name="action" value="" >
So when the user fills out fields and clicks on a submit button, this
window fields, and submits the iframe. The rest of the ifrm.php code then
does the query and spits itself out again. The new ifrm.php output
with the database query results.
The point is, you don't have to hide and unhide the iframe, just leave it
hidden all the time. You can also hide the other input fields in a similar
way if you like, using span or div tags.
Anyway, this is an excellant excuse for the use of iframes. Behind the
scenes database queries can be made without disrupting the user's view of
the rest of the page.