W3C home > Mailing lists > Public > www-html@w3.org > June 2003

RE: Changing 2 iframes at once

From: Asbjørn Ulsberg <asbjorn.ulsberg@nrk.no>
Date: Mon, 23 Jun 2003 08:41:16 +0200
Message-ID: <D186E3C450FED2119AFA00508B08736F06E938D9@MAEXCH05>
To: "'Herr Christian Wolfgang Hujer'" <Christian.Hujer@itcqis.com>
Cc: Cool Richard Contr 10 CES/CERC <Richard.Cool@usafa.af.mil>, www-html@w3.org

Herr Christian Wolfgang Hujer wrote:

>> Is there a way to simultaneously change 2 iframes (or more)
>> with a single event (such as onClick)?
> 
> Depending on your layout perhaps you can change the 2 iframes
> to one iframe containing a page with a frameset with two frames
> or a body with two iframes to achieve your goal?

The best thing is of course not to use iframes at all. Instead,
one should use server side processing, like SSI, PHP or ASP to
include content into different areas of the page.

If the point is to load the content into an area without reloading
the page, one could do this with JavaScript. When done right, this
solution can work both with and without JavaScript or (special)
support for iframes and such. It might look like this:

<a href="mypage.php?action=changeArea&amp;areaId=23&amp;contentId=81"
  onclick="changeArea(23, 82); return false;">Change area content</a>

In this anchor, the href points to a PHP script that receives
arguments for changing area 23 with content 81. When clicked, the
onclick event will be fired in browsers with JavaScript support
and where it's not turned off.

In the onclick argument, the function changeArea() is called. This
function does the same thing as "mypage.php" does, but it doesn't
reload the page because it's all done on the client. The "return
false" statement makes sure that one doesn't gets returned to the
execution of the "href" when done executing the changeArea() script.

The details of what's being done inside "mypage.php" and changeArea()
is outside the scope of this mailing list imho, and is also not
very interesting. The main point is to offer functionality that don't
require too much from the client, which I think both JavaScript and
iframe do. Offering alternatives to iframe is hard, but to JavaScript
it's rather easy.

-- 
Asbjørn Ulsberg           -=|=-          X-No-Archive: No
"He's a loathsome offensive brute, yet I can't look away"
Received on Monday, 23 June 2003 02:41:35 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:15:55 GMT