PDA

View Full Version : Collapsible Frame Script



kerusso
08-06-2006, 10:44 PM
1) Script Title: Collapsible Frame Script

2) Script URL (on DD):http://www.dynamicdrive.com/dynamicindex8/collapsemain.htm

3) Describe problem: The script seems to work fine as long as the frame you want to collapse is the first frameset. Is there a way to target the second frameset? Below is my frameset:

<frameset cols='21%,79%'>
<frame src='menu.asp' scrolling='yes' name='menu'>
<frameset rows='14%,18%,8%,*'>
<frame src='banner.asp' scrolling='no' name='banner'>
<frame src='info.asp' scrolling='no' name='info'>
<frame src='scroller.asp' scrolling='no' name='ref_sel'>
<frame src='contents.asp' scrolling='yes' name='contents'>
</frameset>
</frameset>

The script is called from info.asp and it collapses and restores the frame containing menu.asp with no problem at all. Matter of fact it is flawless. However, I would like to be able to collapse for instance scroller.asp which is in the frame named 'ref_sel' which is in the second frameset. How can I target that frameset?

Thanks...

jscheuer1
08-07-2006, 03:50 AM
from the Demo Page:
Note that this script is not compatible with pages that use a combination of both frame columns and rows.

Not with this script you don't. The fact that it works at all on the top frameset is probably due to its resembling a simple two column setup from the point of view of the browser, as regards the first column, which is not subdivided.

kerusso
08-07-2006, 03:56 AM
Thank you for your response. Is there a work around for this or do you know of another script that will work with multiple framesets?

jscheuer1
08-07-2006, 04:15 AM
Thinking about this a bit more, you could probably take a more direct approach. This is a stand alone command (has nothing to do with the script) that should do that, with the excess height being given to the bottom frame row in the frameset:


parent.document.getElementsByTagName('frameset')[1].rows='14%,18%,0%,*';

If you want the excess distributed differently, adjust the other percentages. To restore it to its original setup:


parent.document.getElementsByTagName('frameset')[1].rows='14%,18%,8%,*';

Notes: If I had a link to your page, I could double check in a few browsers for compatibility. You can use these commands like:


<a href="javascript:void(parent.document.getElementsByTagName('frameset')[1].rows='14%,18%,8%,*');">restore</a>

or:


<a href="#" onclick="parent.document.getElementsByTagName('frameset')[1].rows='14%,18%,0%,*';return false;">collapse</a>

kerusso
08-08-2006, 12:15 AM
Thanks again for your response. I tried the code above and I received an error.

Error: Access Denied
Code: 0

I do not understand what would cause that error. Why would it say Access Denied?

kerusso
08-08-2006, 12:52 AM
jscheuer1...

I just tried the code in a different page. It work perfectly. The page I had it on is vbscrip in an asp page. I added a body tag at the end of this page and that is where I initially placed the script. It is there that I received the Access Denied error. That page also uses ADO to connect to a database from whence I get the data to populate the window. Maybe it is something in that page that is causing the error.

jscheuer1
08-08-2006, 02:46 AM
It could be something much simpler. Framesets and their content pages don't play well together accross domains, especially where javascript is concerned. To put it it more simply, if a content document is on one domain and the frameset is on another, little or no communication is allowed between the two pages using javascript. The error one gets is 'access denied'.

The two pages can even be on the same domain but, if their DNS entries appear different to the browser, say one is expressed as a number and the other as a name, that's all it takes to be denied access.

I once found a way to change a frame's source (the src attribute) across domains but that was it. You cannot even change a frame's location across domains, even though that amounts to the same practical result.