PDA

View Full Version : linking a document into a frame in an already existant frameset


Tombo
05-05-2003, 07:44 PM
Hullo,

Here's what I have:

home.htm <-- the main page
frameset.htm <-- a frameset divided into 2 frames
blank.htm <-- a blank htm page

* for frameset.htm, both of it's frames have blank.htm as their start page.

Imagine home.htm being displayed. It has a single link on it. Clicking this link will make frameset.htm open in a new window, (having 2 frames, each having balnk.htm as their start pages.)

What I want to know is.. how do I modify the link on home.htm so that when frameset.htm pops up I can chose another htm document to appear on one or both of it's frames.

In other words, here's the link on home.htm:

<a href=frameset.htm" target="_new">frameset</a>

Is there something I can insert into that <a> tag so that I can define a page to be opened in one of the frames of frameset.htm?

(I still want frameset to open in a new window, and I'm hoping the method will work even when frameset.htm isn't open in the background.)

Thanks.

joh6nn
05-06-2003, 12:01 AM
there are a couple of different ways to go about this. i think the easiest way though, is to make use of what i call "frame saver" scripts. what they're designed to do, is make sure that a page will always open inside the frameset it was intended to be part of. here's a link to an explanation of such a script that i wrote: http://codingforums.com/ubb/Forum4/HTML/009362.html

there are also several similar scripts floating around in the forums, if that one doesn't seem to work for you.

junkmail
05-06-2003, 03:59 AM
Hi I am not an expert in javascript but if I got your question right then here is a cheap way of doing that

::Home.htm::
<html>
<head>
<script>
var OpenFrame;
function LoadFrame(FrameNumber, FrameLocation)
{
if (FrameNumber== 'Frame1')
{
OpenFrame.Frame1.location=FrameLocation;
}
else if (FrameNumber== 'Frame2')
OpenFrame.Frame2.location=FrameLocation;

}
</script>
</head>
<body>
<a href="#" onClick="OpenFrame=window.open('Frame.htm');">Open Frame</a><br>
<a href="#" onClick="LoadFrame('Frame1', 'NewLocation.htm')">Send Frame1 to NewLocation.htm</a><br>
<a href="#" onClick="LoadFrame('Frame2', 'NewLocation.htm')">Send Frame2 to NewLocation.htm</a><br>
</body>
</html>


::Frame.htm::
<html>
<frameset cols="50%,50%">
<frame src="blank.htm" name="Frame1">
<frame src="blank.htm" name="Frame2">
</frameset><noframes></noframes>
<body>
</body>
</html>

Note The user must click on 'Open Frame' (on home.htm) first to open the frame in a new window so that 'OpenFrame' will have an assigned value to the new window.

Hope that helped you a little
Sorry for miss spellings and bad english (If any)