You are here: Re: Can iframe hide itself? « HTML « IT news, forums, messages
Re: Can iframe hide itself?

Posted by coolsti on 05/26/05 18:23

On Wed, 25 May 2005 16:30:24 +0000, Noozer wrote:

> I have an IFRAME (yes I know that frames are evil) that is made visible
> when 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 some data.
>
> 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?
>
> Thx!

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"
height="0"></iframe></div>

and simply calls a server side php file called ifrm.php when the iframe is
submitted.

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="" >
</form>

So when the user fills out fields and clicks on a submit button, this
calls a javascript which fills the iframes hidden fields from the main
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
contains javascript that fills up the main window fields or select lists
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.

- steve

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация