back to list

another HTML frames question

🔗monz <monz@...>

7/14/2004 11:10:31 AM

how do i need to set up a link on one non-frame page
to have it open the target page *inside* the
Encyclopaedia frame page?

for example, i know that from inside the Encyclopaedia
the link needs to look like this:

<A HREF="filename.htm" TARGET="mainFrame">link-text</A>

but how do i get that page to open that way when the
link tag is *not* already within the Encyclopaedia?
do i have to link to the Encyclopaedia main frame first?
then what?

thanks.

-monz

🔗Robert Walker <robertwalker@...>

7/14/2004 8:38:20 PM

Hi Monz,

> for example, i know that from inside the Encyclopaedia
> the link needs to look like this:

> <A HREF="filename.htm" TARGET="mainFrame">link-text</A>

> but how do i get that page to open that way when the
> link tag is *not* already within the Encyclopaedia?
> do i have to link to the Encyclopaedia main frame first?
> then what?

That's a VERY tricky one!

Some time back I wanted my pages in the help for
FTS to be able to link to the frame for the
same page so each page could show a frames / no frames
link.

I ended up with a rather clumsy solution, but
one that works. I made a separate frame for eaach
page that I wanted to show embedded.

So in my help pages,
faq_doc.htm for instance is
exactly the saem as index_doc.htm but the
page it loads is faq.htm instead of index.htm

So if I want to load faq.htm in the target
frame I just link to faq_doc.htm.

The problem with most other ways one
might try to do it is that if you load
the url for the frame and set the target for the frame
for it after loading it (if loading into the
current window that is), then by the time
the frame is loaded, as a result of loading
it, the javascript you want to use to set the
frame target is gone, so it never gets to that
next line and doesn't do anything.

You could do it probably if you always
load the frame into a new window
to avoid disturbing the current window,
and then set the target of the frame
in javascript, but
that means endless popups.

However, just did a google
search and there is a neater solution!
But it does have a drawback unfortunately.

http://developer.irt.org/script/488.htm

from:
http://developer.irt.org/script/frame.htm
which seems a great resource for checking
up how to do tricky things with frames.

You don't need the ampersand parsing there though
if it is just one page to be loaded.

How it works then, leaving the ampersand parsing out,
is to pass the page to be loaded
as part of the url using
e.g.
<a href="frame.htm?faq.htm">
and parse the url in the javascript
using

<script language="JavaScript">
<!--
input = location.search.substring(1);

Then input there will be the url that
you passed in the href, so now
what you do in javascript is
to construct the entire frame
dynamically using

document.write('<frameset cols="20%,*">');
etc, same thing for every line in your
frame page, then when you get to the
part where you want to use the url,
use
document.write('<frame src="' + input + '">');

Here is the complete code for a couple
of test files I have just done:

test.htm

<HTML>
<HEAD>
</HEAD>
<a href="frame.htm?faq.htm">test should load frame with faq</a>
</HTML>

frame.htm

<HTML>
<HEAD>
</HEAD>
<SCRIPT LANGUAGE="JavaScript">
input = location.search.substring(1);
document.write('<FRAMESET COLS="25%,*" border="0">');
if(!input)
input="index.htm";
document.write('<frame name="contents" src="contents.html">');
document.write('<frame name="help" src="' + input + '">');
document.write('</frameset>');
</SCRIPT>
</HTML>

+ example files for index.htm, contents.htm and faq.htm

This works in IE 5, Netscape 4 something, Opera
(my version of it) but _not_ in Mozilla Firebird.

One definitely wants ones pages to work in Mozilla
aa an up and coming new browser that lots of people
think is really good. So I don't know if
there is a work around for that...
Anyone got any ideas? I think it is the
document.write(...) that is puzzling
Mozilla for some reason as it still
can't do it if you remove all the
url parsing.

Robert

🔗monz <monz@...>

7/15/2004 9:32:51 AM

hi Robert,

--- In metatuning@yahoogroups.com, "Robert Walker" <robertwalker@n...>
wrote:

> Hi Monz,
>
> > for example, i know that from inside the Encyclopaedia
> > the link needs to look like this:
>
> > <A HREF="filename.htm" TARGET="mainFrame">link-text</A>
>
> > but how do i get that page to open that way when the
> > link tag is *not* already within the Encyclopaedia?
> > do i have to link to the Encyclopaedia main frame first?
> > then what?
>
> That's a VERY tricky one!
>
> <etc. -- snip>

wow, thanks for all of that. it's going to take me
some time to digest it all, and to set up some experiments
of my own to see if (and how) it all works. thanks!

it seemed to me that there should be an *easy* way to
do this kind of thing. oh well ...

-monz

🔗Robert Walker <robertwalker@...>

7/15/2004 5:18:14 PM

Hi Monz,

I just found out why that test in Mozilla Firebird
didn't work. There are several possible ways of
doing the end of lines.

Usual ones are carriage return and line feed
used in various combinations.

But there is another very rare one - the
vertical tab. It is used by Microsoft Word
in some contexts though I don't think
I was using that here. Anyway, somehow my code had got
saved with a couple of vertical tabs
possibly pasted from another document.

All the other browsers recognised those
as new lines, but Mozilla Firebird
(also Firefox) which are strictly speaking
betas by the way - they didn't recognise
it, treated it as a garbage character, and that
apparently skewed up the html for the
whole page. Just opening the file
and resaving it in Wordpad was enough
to fix it.

More about the line feed characters here:

http://www.unicode.org/unicode/standard/reports/tr13/tr13-5.html

So anyway, if saved in a normal text editor these
should now be okay as examples of how to do it:

I've put up an example web page with a downloadable
zip of the code:

http://www.tunesmithy.netfirms.com/test_load_into_frame/test.htm

BTW I found another site that shows how to
show definitions of highlighted words in
a window. But it works in all the browsers so far
except for Opera. So more work needed, but here
it is as it is so far:

http://www.tunesmithy.netfirms.com/test_show_defs/index.htm

Robert