471,086 Members | 826 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,086 software developers and data experts.

Collapsible Frame JavaScript

I have framset with leftFrame, mainFrame, TopFrame.

I found this script :
http://www.dynamicdrive.com/dynamici...llapsemain.htm

I wonder if it could be ajusted so that it collapses the same frame
that calls it. As it is, If I put the function in the left frame it
decreases the size of the topFrame. I want it to collaps itself.

Is this doable, if not could you please point me to some other resource
where I could do it.

Thanks!

Jul 23 '05 #1
9 3348
books1999 <bo*******@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
I have framset with leftFrame, mainFrame, TopFrame.

I found this script :
http://www.dynamicdrive.com/dynamici...llapsemain.htm

I wonder if it could be ajusted so that it collapses the same frame
that calls it.


If that's all you want to do, you don't need a stand-alone script, just
insert the necessary code into a suitable link.
These two examples should collapse the lower or rightmost of a pair of
frames respectively, and can be located in either.

<A
HREF='#'onclick='if(document.body)parent.document. body.rows="*,0"'>Collapse<
/A>

<A
HREF='#'onclick='if(document.body)parent.document. body.cols="*,0"'>Collapse<
/A>

I don't know why you'd want to do this, but I suggest you include a
restorative link in the remaining visible frame. The syntax should be
obvious.
Another refinement would be to generate the links with document.write, so
that they don't appear if script is disabled or the required support is
un-available.

if(document.body)
document.write(....)

--
Stephen Chalmers http://makeashorterlink.com/?H3E82245A

547265617375726520627572696564206174204F2E532E2072 65663A205451323437393134

Jul 23 '05 #2
Ok here is what I want in a bit more detail.
I want to put a click link in the <frame name=menuFrame src="menu.cfm"
scrolling="no"> so that this frame becomes 5 pixels and when i click it
again it should become 230 as it is when the page loads. Can you please
tell me how this is done becauase my JS is null?
<frameset border="0" rows="24,*" frameBorder="no" frameSpacing="0">
<frame name=TopFrame src="top.cfm" noresize scrolling="no">

<frameset border="0" cols="230,*" frameBorder="no" frameSpacing="0">
<frame name=menuFrame src="menu.cfm" scrolling="no">
<frame name=mainFrame src="main.cfm">

</frameset>
</frameset><noframes></noframes>

Jul 23 '05 #3
books1999 <bo*******@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Ok here is what I want in a bit more detail.
I want to put a click link in the <frame name=menuFrame src="menu.cfm" scrolling="no"> so that this frame becomes 5 pixels and when i click it again it should become 230 as it is when the page loads. Can you please tell me how this is done becauase my JS is null?
<frameset border="0" rows="24,*" frameBorder="no" frameSpacing="0">
<frame name=TopFrame src="top.cfm" noresize scrolling="no">

<frameset border="0" cols="230,*" frameBorder="no" frameSpacing="0">
<frame name=menuFrame src="menu.cfm" scrolling="no">
<frame name=mainFrame src="main.cfm">

</frameset>
</frameset><noframes></noframes>

This link saves including a separate script, at the expense of having
to modify it if you change the default frame sizes.
Put it in the body of either document (all on one line), but if you
put it in the collapsing frame as you describe, I forsee a possible
operability issue...

<A HREF='#' onclick='if(document.body){var
fc=parent.document.body.cols; parent.document.body.cols=(fc=="230,*" ?
"5,*" : "230,*");}' >Collapse/Restore</A>

--
Stephen Chalmers http://makeashorterlink.com/?H3E82245A

547265617375726520627572696564206174204F2E532E2072 65663A20545132343739
3134

Jul 23 '05 #4
Stephen this link reports an invalid character error and it does not
collapse the frame.

<A HREF='#' onclick='if(document.body){var
fc=parent.document.body.cols; parent.document.body.cols=(fc=*="230,*"
? "5,*" : "230,*");}'>Collapse/Restore</A>
Can you please tell me what is wrong with it?

Jul 23 '05 #5
books1999 <bo*******@hotmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Stephen this link reports an invalid character error and it does not
collapse the frame.

<A HREF='#' onclick='if(document.body){var
fc=parent.document.body.cols;
parent.document.body.cols=(fc=*="230,*"
? "5,*" : "230,*");}'>Collapse/Restore</A>
Can you please tell me what is wrong with it?

I told you to put it all on one line, not wrapped as it may appear.
Using the example in this message, remove the newlines and ensure no
words become joined together

--
Stephen Chalmers http://makeashorterlink.com/?H3E82245A

547265617375726520627572696564206174204F2E532E2072 65663A20545132343739
3134


Jul 23 '05 #6
Hi Stephen,

I originaly put it in one line but the mistake was in a minus sign that
I accidetnaly put when i removed the newlines.

Now here is the problem. When I clicked on the link, it put all the
frames, all three of them in the top frame! plus creating one more.

Do you know what might be the problem?

Jul 23 '05 #7
Hi Stephen,

I originaly put it in one line but the mistake was in a minus sign that
I accidetnaly put when i removed the newlines.

Now here is the problem. When I clicked on the link, it put all the
frames, all three of them in the top frame! plus creating one more.

Do you know what might be the problem?

Jul 23 '05 #8
"Logic Al" <ig******@lycos.co.uk> writes:
books1999 <bo*******@hotmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com... Stephen this link reports an invalid character error and it does not
collapse the frame.

<A HREF='#' onclick='if(document.body){var
fc=parent.document.body.cols;
parent.document.body.cols=(fc=*="230,*" ^
There is an extra "-" between the two ='s, that shouldn't be there,
i.e., "=-=" should be just "==".
? "5,*" : "230,*");}'>Collapse/Restore</A> Can you please tell me what is wrong with it?
It should be a button, not a link. Links are for linking to content,
buttons for doing things (but that's a usability problem, not a
programming error :).

There is no need to define a variable if the value is only used once.

Try just:

<button type="button" value="Collapse/Restore"
onclick="if(document.body){
parent.document.body.cols =
(parent.document.body.cols == '230,*') ? '5,*' : '230,*';
}">
I told you to put it all on one line, not wrapped as it may appear.


Attributes can contain newlines, so it doesn't need to be one line.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #9
Same problem with Lasse's example.

All the frames end up in the top frame.

Thanks!

Jul 23 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by clintonG | last post: by
2 posts views Thread by develeigh | last post: by
7 posts views Thread by Kamal | last post: by
7 posts views Thread by David T. Ashley | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.