tags:

views:

440

answers:

3

I'm working on a table of links within a site using iframes. I'm wondering if there's any way to code a link to go to two simultaneous destinations within two different target frames? I've been reading all afternoon and can't find anything close to what I want to do. Basically I want one link to present a photo in one iframe and some data in another iframe. Any ideas?

+3  A: 

Short answer: No.

Longer answer: With what you describe, using strictly X/HTML, this isn't possible. You could add in javascript to change the iframe src, however. Something like:

function click_link(id) {
    document.getElementById('iframe1').src = "page.ext?id=" + id;
    document.getElementById('iframe2').src = "other_page.ext?id=" + id;
}

But of course, you probably shouldn't be using iframes anyways...

davethegr8
+1  A: 

The easy way is javascript, but that method has been answered already. The only way to do this (without relying on javascript) is serverside.

Make your <a target > link back to the top frameset that contains all the frames you want to change and on the serverside change the src attributes of the frames.

Kris
This only works if you're okay losing the parent/local frame's state
eyelidlessness
That's correct in probably at least 99.9% of all cases. Can still be remedied storing state outside the page _and_ using some form of keyed session based state in combination with url rewriting before outputting your pages or somesuch.
Kris
A: 

Don't use frames. They're bad for usability, bad for SEO, and cause problems like this.

This may seem unhelpful advice, but really in the long run you'll avoid a lot of headaches.

If you merge files on the server side, they'll work without problems in every browser, search engine, etc. Reloading of a simple page doesn't have to be slower than loading of 2 iframes.

Or, in case of showing photos with descriptions, a simple DHTML could do the job:

img.onclick = function(){
   $('bigphoto').src = this.src.replace(/_small/,'_big');
   $('description').innerHTML = this.title;
}
porneL