PDA

View Full Version : Saving the locations of frames and re-writing frameset code...


werp
08-29-2002, 12:37 PM
Problem Scenario

I'm making a site that uses frames:

One is the menu frame, and the other is the content frame. What I need is buttons that, when pushed, minimize and maximize the menu frame, for example between 20px and 100px by rewriting the frameset code AND maintaining the document locations of the two frames, i.e. from the user's point of view, nothing changes but the size of the frames.

So far I've managed to make the frame resizing code, now I just need a way to read the locations of the frames somewhere so I can rewrite the frameset code with proper frame SRCs.

Somebody, save my day please :(


PS. The frame resize thingie is based on this (http://www.interface.hu/scripts/article/DynamicFrameSize/index.htm) article on interface.hu.

Mr J
08-29-2002, 02:50 PM
Not sure if this may help but take a look at this example of collapsing frames.

www.huntingground.freeserve.co.uk/webplus/frames/collapse/collapse.htm

werp
08-29-2002, 03:02 PM
That looked promising at a first glance but then I noticed it doesn't work on NS4.* ... which really is a must in this case :(

If you (or anybody) know a workaround for making it crossbrowser, please do tell.

Thanks anyway Mr J. :)

joh6nn
08-29-2002, 06:12 PM
can we see the code you're using right now? that might help us come up with something.

Mr J
08-29-2002, 07:28 PM
The following is copied into the <Head> section of the Frameset document.

<script language="JavaScript1.2">
<!--
defaultconf=''
function expandf(){
if (document.all){
if (document.body.cols!="10,*")
document.body.cols="10,*"
else
document.body.cols=defaultconf
}
}
// -->}
</script>

The following is copied into the <Head> section of the document which is going to be shown in the frame to be collapsed

<script language="JavaScript1.2">
<!--
if (document.all)
window.parent.defaultconf=window.parent.document.body.cols
function expando(){
window.parent.expandf()
}
document.ondblclick=expando
-->
</script>


Would it be a case of just removing the reference to "if (document.all)"

Mr J
08-29-2002, 07:29 PM
the above is for joh6nn to peruse

joh6nn
08-29-2002, 08:01 PM
no, i don't think so. i'm pretty sure that's there because the code simply won't work in NS4, but i don't have NS4, so i can't test it to be sure. i'm wondering if window.resizeTo() would work, but i doubt it. i'm thinking that werp is right in assuming that dynamically writing the frameset is the only way to make this work cross browser, but frankly, i'm not fond of that solution because it means reloading the page every time, and having to keep track of the page that you were on.

i'd like to see the code that werp is using. that might give me some ideas, and if it doesn't, i'll bet it would do something for the other people following this thread.

werp
08-30-2002, 08:37 AM
I should've mentioned this in the first post already:
The resizing & maintaining frames' document.locations must be pretty much unibrowser, as in IE 4.x and higher, NS 4.x and higher. Opera and Mozilla compliance isn't that important but this current resizing method from an interface.hu article (http://www.interface.hu/scripts/article/DynamicFrameSize/index.htm) does it for all these browsers. :o

So anyway, here's some ways of doing it:

Example 01 (http://asenne.org/resize/01/)
Based on the interface.hu technique (http://www.interface.hu/scripts/article/DynamicFrameSize/index.htm). Just play with the minimize and maximize buttons. This works currently with IE 4.x and higher, NS 4.x and higher AND Current Mozilla and Opera, which is just great :p It doesn't remember frames' locations tho, it just loads the pages defined in the frameset code (which actually is the big problem here).

Example 02 (http://asenne.org/resize/02/)
Here's an alternative which a friend of mine came up with... It just resizes the menu frame, thus being ideal because it doesn't REload the frames' contents - if only it would work on others than IE, too :(

Mr J's Link (http://www.huntingground.freeserve.co.uk/webplus/frames/collapse/collapse.htm)
This is what Mr J posted earlier - It seems nice, buuuut only works on IE :(



So far I'm bound to think that the resizing & saving locations is the only true crossbrowser/unibrowser way of doing the needed.

joh6nn, here's the codes for the Example 01, on which I've been building the whole thing so far:

Frameset Code (view-source:http://asenne.org/resize/01/index.html) -- Menu Code (view-source:http://asenne.org/resize/01/menu.html) -- Frameset Code (view-source:http://asenne.org/resize/01/content.html)

The codes were too long to be posted here... ;)

Anyway, all help is still appreciated, I'm waiting your wise advises :thumbsup:

glenngv
08-30-2002, 09:48 AM
Originally posted by werp
Problem Scenario

So far I've managed to make the frame resizing code, now I just need a way to read the locations of the frames somewhere so I can rewrite the frameset code with proper frame SRCs.


top.frames['frameNameHere'].location.href

werp
08-30-2002, 10:29 AM
Thanks glenngv!

But how do I implement that in practise, so that when the user loads the frameset for the first time, it is written with the menu.html and content.html, but when the frames' locations change and user resizes the frameset, the locations stay the same they at that particular moment, i.e. not reloading to menu.html and content.html again?

glenngv
08-30-2002, 10:45 AM
that will dynamically get the current URL of the specified frame. you can call it anywhere in your frame1 or frame2, that will depend on your design

joh6nn
08-31-2002, 12:35 AM
example two ( here (http://asenne.org/resize/02/)) actually works in Mozilla. all i had to do was shift it from document.all to document.getElementById(). unfortunately, it didn't work in NS4, when i tried it with document.ids[]; plop.rows was undefined.

as for using top.frame['topFrame'].location.href, you append it to top.location, just like you did with the new information for the framesets.