PDA

View Full Version : force bookmarking to specific frame?


patrik
09-12-2002, 09:45 PM
In a frames environment, is it possible to specify which frame is recorded when a user bookmarks the page?

Thanks!

joh6nn
09-12-2002, 10:00 PM
http://codingforums.com/ubb/Forum4/HTML/009362.html

patrik
09-12-2002, 10:11 PM
Thanks, but I fear I may not have communicated my problem.

I already have a similar (if not the same, in which case THANKS again!) script in place so that a bookmarked frame will open in it's correct place.

What I want to do is to specify which frame in a frameset gets bookmarked when a user pulls down Add Bookmark/Favorite from his browser menu.

..or am I misunderstanding your post?

Thanks again

zoobie
09-13-2002, 12:39 AM
The problem is those bookmarking scripts just throw the site into the favorites filing cabinet. Most don't use/like the bookmarking script. If they like your site, they will bookmark it by placing it into their proper folder in their favorites. I wouldn't even bother.

joh6nn
09-13-2002, 12:50 AM
yeah, i'm with Zoobie: stay away from the bookmarking scripts. if you want to ensure that people are bookmarking the appropriate page in your frames, then i suggest putting <script>document.write(document.URL);</script> on all of those pages. it will automatically write the URL of that page for you, so that your visitors know what the REAL url is. it's a much more friendly way of doing things.

Spookster
09-13-2002, 02:51 AM
Or a possilbe solution could be to set focus to the particular frame that you want bookmarked.

patrik
09-13-2002, 04:50 PM
Spookster wrote:
Or a possilbe solution could be to set focus to the particular frame that you want bookmarked.

=========

This is pretty much what I had in mind. How does one do this?

Thank you all for all the suggestions/comments - very good food for thought!

patrik
09-13-2002, 09:01 PM
My javascript reference says this about the focus() method of the Frame object:

"The focus() method of the Frame object is used to set the focus to a specific frame."

This sounds exactly like what I want to do. I have a frameset where I would always like one frame (named "content") to have focus, so that a user making a bookmark/favorite would get that frames URL.

The example given (it appears to be directly before the frameset command) is:
<script>
//set initial focus to bottom frame
document.bottom.focus;
</script>

Short but sweet. I assume that since focus is dynamic, it won't be enough to have it at the top of the document, but it would likely need to be executed after anything that would change the focus (such as a user clicking on one of the script-generated links in a navigation frame).

How can this be implemented? I get an error. I assume that since the frame I want to focus on is called "content", my version of the example above would be:

document.content.focus;

Any help with this would be VERY gratefully appreciated - and I promise, no more questions today!

joh6nn
09-13-2002, 10:24 PM
well, i know that the following will set the focus on a page, but i'm not sure that it will help you with your bookmarking thing.

<script>
self.focus();
</script>

brothercake
09-14-2002, 03:10 AM
It is not possible to bookmark a specific combination of pages in a frameset, because that is a non-addressible state.

If you want to do that you would need to encode the frameset content into the main url, so that you could call it something like

frameset.html?main=main.html&left=navpage.html&top=statictop.html

But the bookmarking logic of a web browser wouldn't be able to do that automatically - it would be up to you to track the user's progress through your site and update the main url accordingly.

joh6nn
09-14-2002, 03:48 AM
that's not what he's looking for. he's looking for a way to force the browser to bookmark the content page, instead of the framset page. not possible, or at the very least, not easy, in my opinion.

swallow
09-14-2002, 10:58 AM
Joh6nn,

I saw the discusion that you provided a link for. Where in the code do those scripts go? In the head of each of teh respective pages?

Actually I tried a two part script in provided in another thread. I was trying to navigate from a "no frames" page to a frames page. You can see the results:

http://www.dingliswallows.com/testing/frameset.htm

http://www.dingliswallows.com/testing/noframes.htm

I was tickled pink when it worked. I incorporated into a few pages of my site in order to refer to them through a newsletter. It worked fine initially then suddenly it kept reloading my "first page". I cannot understand it. The strange thing was that in the address field in the toolbar there was evidence that the script was actually attempted. :confused:

I may try out your script so could you tell me where those scripts go in the code?

Thanks

Spookster
09-14-2002, 11:40 AM
Swallow,

You need to create your own topic for this as it is off topic to this thread.


Patrik,

Here is another solution:

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

swallow
09-14-2002, 12:20 PM
Spookster,

I actually started a separate thread a couple of days ago. It had plenty of views but no respondents. :( I thought as this was somewhat related I could join into the discussion. Anyway I started the post by asking joh6nn something about one of his answers.

Spookster
09-14-2002, 01:50 PM
It is related but it is better to keep both in seperate threads so for others that come along and have similar issues they will not get confused with two different discussions about two related topics.

swallow
09-14-2002, 01:55 PM
True. I am trying to find the original thread by me but cannot find it presently.

Spookster
09-14-2002, 02:29 PM
Originally posted by swallow
True. I am trying to find the original thread by me but cannot find it presently.

http://www.codingforums.com/showthread.php?s=&threadid=6014

patrik
09-16-2002, 09:40 PM
Good news! For most of my needs, inserting Joh6nn's suggestion into my content files:
self.focus();
works perfectly - and is elegantly simple. Thanks Joh6nn!

However, there is one more instance where I need this functionality - when a user clicks on an email link in a separate frame, I want to refocus on the content frame. I've tried adding another onclick function to the email link. I think this should work, but it doesn't. Is this feasible - what am I doing wrong?

Here's my code:
document.write('<a href="#" onclick="location=\'mailto:' + name + '@' + domain + '\' + top.content.document.location.href;document.content.focus">Webmaster</a>');

Thank you all for your help, commentary and advice!

patrik
09-16-2002, 10:54 PM
ARGH! I spoke too soon!

Apparently, the "self.focus();" script that I put in the header of the files that will load into my content frame works perfectly in Mac NN 4.77, but NOT in Mac IE 5, nor in Windows NN or IE.

In these it kind of works; bookmarks reflect the overall frameset, not the content frame. This is still better than bookmarks reflecting the navigation frame which was the previous status quo - but it worked so nicely from Mac NN! Under Mac NN, focus was on the content frame so that was what got bookmarked, and if you printed, that was what got printed!

Under IE (and Windows NN), now the focus goes to the main frameset, and what prints is the navigation frame (which has the links to the content pages)!

Why is this, and is there a way to get it to work in newer, more mainstream browsers than Mac NN4.7?

Thanks once again - and sorry to be bugging you all!

joh6nn
09-17-2002, 06:05 AM
see, this is what i was talking about. the focus, to the best of my knowledge, isn't going to greatly effect the outcome. getting things to work right it is going to be based more on what i initially suggested: letting the users know what the url of the content frame is, and letting them bookmark it themselves, and similiarly, letting them print it themselves. it's entirely possible that there are scripts out there that take care of these problems, but i've yet to see them.

patrik
09-18-2002, 05:20 PM
I see your point.

Having that focus command in the content files just seemed like a simple, effective solution (if it would have just worked the way it is supposed to, anyhow)..

I am somewhat surprised it is the old NN browser it works in, and not IE - but oh well..

Thanks everyone for your input - I have a much better understanding of the issues now, and FWIW, this technique -while not solving the problem- does improve the situation a fair bit. I will also implement the more friendly, non-automated fix.

Thanks again!