Restoring frameset context?

M

Mark

Hello.

I am working on a common problem. . .restoring frameset context when a user
links directly to a page.

Loading the frameset isn't a problem. . .there are numerous examples of
simple Javascript procedures that will do it, like this:

if (top.location.href.indexOf("../index.html") == -1)
top.location.href = "../index.html";

I have that working just fine. However, the frameset displays the default
document in the target frame.

A more complex problem, it seems, is identifying to the frameset which
content the user linked to, and displaying that content in the target frame.
One approach is some fairly complex Javascript that rewrites the frameset,
as shown here:

http://www.webreference.com/js/column36/forcing.html

Is there a simpler way? It would be especially nice if the frameset document
didn't need to know up front the names of all the pages that it might be
called upon to display.

Thanks
-Mark
 
T

Tom

Mark said:
I am working on a common problem. . .restoring frameset context when a
user links directly to a page.

Loading the frameset isn't a problem. ...
A more complex problem, it seems, is identifying to the frameset which
content the user linked to, and displaying that content in the target
frame. One approach is some fairly complex Javascript that rewrites the
frameset, as shown here:

http://www.webreference.com/js/column36/forcing.html

Is there a simpler way? It would be especially nice if the frameset
document didn't need to know up front the names of all the pages that it
might be called upon to display.

Their approach seems a little silly, yes. Would this perhaps be enough (from
http://4umi.com/web/javascript/snips.htm#framerelocator)?

// in each page, somewhere after the <body> opening tag
if( top===self || top.location.hostname !== 'www.mydomain.com' )
document.write( '<a href="http://www.mydomain.com/frame.html?' +
location.href + '">' +
'View this page in its ' + ( top == self ? '' : 'own ' ) +
'frames</a>.' );

// in the frameset, do not omit <noscript><frame
src="default.htm"></noscript>
document.write( '<frame src="' + ( location.search.substring(1) ||
'default.htm' ) + '">' );

It supposedly displays different messages depending on whether the page is
framed by the wrong site or not framed at all. The re-framing is not done
automatically but offered to the user via a normal link. That 's especially
nice I think.
hth
Thomas
 
M

Mark

Tom said:
Their approach seems a little silly, yes. Would this perhaps be enough
(from http://4umi.com/web/javascript/snips.htm#framerelocator)?

Ok, that is simpler. It still uses the document.write() method, perhaps that
is unavoidable.

So is the following example a standard URI syntax for loading a frameset
(index_frameset.html) and then instructing that frameset to display a
specific document (target_content.html) in a target frame?

http://www.mydomain.com/index_frameset.html?target_content.html

I have tried this syntax in both IE and Firefox, but it doesn't work. Not on
my site anyway.

Thanks
-Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top