Forum Moderators: mack
I dont have any dreamweaver experience so this will be very general...
Are you using true iframes or a standard framed webpage? Iframes are inline frames and are used to include content within a page. Framed pages are used when you want to display seceral pages within one page.
In either case it is possible to make things happen on other frames by specifying the target frame. The target frame determines where you want the action to occur.
Mack.
Perhaps you can have a look at my site <snip> for clarity. The "$499 Spring Special" and "Call 447" are both iframes that I wish to use to display a thumbnail index for project pictures to be available for my clients. When the references button is pressed, it would be nice to change the $499 Spring Special (which will be a fall special at the rate my web page is advancing) ... to change this to "Work Gallery:" as the other center iframe (where the slow house is) changes to another .htm I just don't know how to make two different .htm appear in two different iframes in the one page when one button is pressed. Thanks.
[edited by: mack at 12:42 pm (utc) on May 31, 2005]
[edit reason] No url's please [/edit]
What you want to achieve is not directly possible with HTML, you'll need some Javascript to do that. Basically it would look like this:
1. put a script in the <head> section of your page (you already have a <script>-tag there, so you can just add the function).
function chngFrm() {
frames['topframe'].location.href='page1.html';
frames['bottomframe'].location.href='page2.html';
return false;
}
2. now you need to call that script from your link. Put the function call in the onClick method and leave the href empty:
<a href="" onClick="return chngFrm();" The link won't acutally be processed because of the "return false" in the function.
The downside of that solution is that you have to use Javascript, which maybe not all your viewers' browsers can use.
How about changing the site concept a bit instead? You could put the items you have in iframes in a table-based layout, and then just make a second page that will be called when someone clicks the link, with the items you want to be shown then. That would avoid the Javascript.
Alex
Yeah, it works beautifully in IE but no so good in Safari :(
Q. How would I create several different funtions, so that if I click on one link it will change two frames and if I click on the other link it will change other forms? Do I assign a value to the chngFrm? or ...
Okay, stumped again. So close. Can I expect the same response from within the iframe? That is, when I selected a link from within my index.htm it will open a second .htm within the toptable. Can I click a button within this second .htm to change two frames within the index.htm?
Do I need to assign a relative path?
I like to reference myself at times to the physical things in our nature, I've always been this way. And it's funny how yesterday I tried everything and finally collapsed at the foot of my wall. Yet today my fingers execute a few dextrous strokes and everything works just the way I planned. I like to believe that I am within a bearing spinning symmetrical to my surroundings and that I must wait for my surroundings at times to catch up with me (or me with them) so that my surroundings and I may spin as a whole rather than just sit spinning in my bearing.
"Every man imposes upon himself a resistance for survival, and it is in the end that his efforts shall make him." -- Joah
[edited by: mack at 10:29 am (utc) on May 31, 2005]
[edit reason] Merged posts [/edit]
no, sorry, I must be another Alex. But well, you never know till you ask :)
Okay, to your scripts:
On the main page, I'd change the function somewhat:
Instead of creating a new function for each frame change you want to make, you can assign parameters:
function cngFrm(top, right) {
frames['topframe'].location.href = top;
frames['rightframe'].location.href = right;
return false;
}
Thus, you'll need only one function, which you can call respectively:
<a href="" onClick="return cngFrm('about.htm', 'about header.htm')">
same for the other links, with different parameters. Saves some code and you'll know what's opening when you look at the link code.
With the change from one of the frames, you're actually on the right track already:
function residentialFrm() {
parent.frames['/index.html/topframe'].location.href='residential commercial.htm';
parent.frames['rightframe'].location.href='residential header.htm';
return false;
}
parent.frames calls the frames collection on the parent window, that would be the main page. You should just replace
frames['/index.html/topframe'] with frames['topframe'], you can't have a relative reference there, just the frame name. The relation is done by the parent keyword already. I can't try it in Safari because I don't have a Mac around, but in theory it should be working there, too. Javascript is enabled?
Internet Explorer is the most common browser still, true, but Mozilla-based ones are catching up. You might want to try it also in Firefox, for example. Your page works fine there, though.
okay, I hope I could help you along. Have a nice day, and don't let your page get down on you so much, after all, it's just html :D
Alex
You can target as many frames (or elements as you like) as long as it is event driven.
You can control any element from any element when using the DOM
If you were to look into using a frameset instead of the Iframe you could use the DOM (document Object Model) to control what is loaded in the two frames, in fact you could check to see what is loaded in frame 1 and load frame 2 based on frame 1's content.
The trouble with Iframes is that they have no parent, when using a frameset you can target elements within...
parent.main.location.href("page to load")
Frameset's are very useful for this type of thing.
Good luck
parent.frames[<name of targetframe>].location.href from an IFrame.