Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help getting links in a cascading menu in one frame to open in another

Status
Not open for further replies.

InterlinkModule

Technical User
Sep 13, 2005
80
0
0
US
I'm using the built in DHTML cascading menu builder in the CoffeeCup 2007 HTML Editor. It seems to work fine, but the problem is this: I have a two frame page, as follows:

<frameset rows="10%,*" border="0">
<frame name="darkness" src="frame.html" marginwidth="10" marginheight="10" scrolling="auto" frameborder="0" noresize>
<frame name="dissolution" src="dissolution.html" marginwidth="10" marginheight="10" scrolling="no" frameborder="0">
</frameset>

This is my index page. The Javascript menu is contained in frame.html and an intro/welcome page in dissolution. I want *any* link that is selected in the cascading menu in the top frame to open in the bottom frame, preserving the menu in case the user wants to navigate elsewhere on the site. I'm fairly new to Javascript and don't yet have the expertise, altho it reminds me a lot of my C++ days. I've found the area in the code that I think should be responsible for the frame locations but I'm not sure. Here is the part I believe it is:

if(FrstCreat){
if(FirstLineFrame =="" || !parent.frames[FirstLineFrame]){
FirstLineFrame=SecLineFrame;
if(FirstLineFrame =="" || !parent.frames[FirstLineFrame]){
FirstLineFrame=SecLineFrame;
if(FirstLineFrame =="" || !parent.frames[FirstLineFrame])FirstLineFrame=SecLineFrame=DocTargetFrame=''}}
if(SecLineFrame =="" || !parent.frames[SecLineFrame]){
SecLineFrame=DocTargetFrame;
if(SecLineFrame =="" || !parent.frames[SecLineFrame])SecLineFrame=DocTargetFrame=FirstLineFrame}
if(DocTargetFrame =="" || !parent.frames[DocTargetFrame])DocTargetFrame=SecLineFrame;
if(WebMasterCheck){ if(!Check('Menu',NoOffFirstLineMenus)){status='build aborted';return}}
FrstLoc=FirstLineFrame!=""?parent.frames[FirstLineFrame]:window;
ScLoc=SecLineFrame!=""?parent.frames[SecLineFrame]:window;
DcLoc=DocTargetFrame!=""?parent.frames[DocTargetFrame]:window;
if (FrstLoc==ScLoc) AcrssFrms=0;
if (AcrssFrms)FirstLineHorizontal=MenuFramesVertical?0:1;
FrstWinWdth=ExpYes?FrstLoc.document.body.clientWidth:FrstLoc.innerWidth;
FrstWinHght=ExpYes?FrstLoc.document.body.clientHeight:FrstLoc.innerHeight;
ScWinWdth=ExpYes?ScLoc.document.body.clientWidth:ScLoc.innerWidth;
ScWinHght=ExpYes?ScLoc.document.body.clientHeight:ScLoc.innerHeight;
if(Nav4){ CntrTxt=MenuTextCentered!='left'?"<div align='"+MenuTextCentered+"'>":"";
TxtClose="</font>"+MenuTextCentered!='left'?"</div>":""}}

The frame location should be related to the var DocTargetFrame according to the var defitions at the start of the script. So, how can I get links clicked on in the top frame menu to open in the bottom frame? I've examined several related scripts and can't figure it out as there are significant differences.

Also on the subject, is there a way to preserve the menu if someone starts hitting the back and forward buttons on the browser? I tested it briefly, and the menu just vanished on several occasions....

Thanks!

-=<>=-
 
Man... seriously, that code is a complete mess. The first 2 if blocks are the exact same, down to the character. If blocks are mixed with ternary operators. There's absolutely no indentation at all to help portray the flow of the code. There's a condition on almost every line, but you haven't provided what the variables in the conditions represent - so any suggestion would be a complete and total guess.

Additionally, it's one thing to ask for help on a forum when you are having difficulty getting some code to work that you wrote. But to take some code that someone else has written, and then ask someone completely different to tailor it to your needs is kinda bordering on laziness, don't you think?

My suggestion - contact the original author of the script and ask them to explain it to you. They will have a much better grasp of what the code is doing than any of us will (even though it looks like garbage). You said that you have C++ experience, and javascript uses the same curly brace syntax so you shouldn't have that much of a problem doing this yourself.

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
InterlinkModule said:
The frame location should be related to the var DocTargetFrame according to the var defitions at the start of the script.

I'm assuming there is a good reason why you'd keep those definitions a secret? As kaht points out, it's hard enough debugging the sort of crappy code you get from those 'download-a-script' sites. Debugging part of it without knowing what else is going on is nigh on impossible.

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]

Webflo
 
Try this

W3schools

--Dan
Whenever you find yourself on the side of the majority, it is time to pause and reflect.
Mark Twain
 
As was stated, no one "wrote" the code. I am using a program called CoffeeCup that aides in the building of advanced websites (more advanced than straight HTML which I already know). I used said program's *built in* DHTML cascading menu builder. The second set of code was generated automatically after I typed in the links that I wanted to use and chose colors and style attributes.

I simply need a bit of coding help to correct the frame issue as I'm still new to Javascript. I'll go ahead and attach the entire script and I'll also include the var section below. Keep in the mind, the menu is not finished (for my site) but the attached script is functional (tested in Firefox v2).

These are all the main vars at the top of the script.

Thanks!

var NoOffFirstLineMenus=3; // Number of first level items
var LowBgColor='4B4B4B'; // Background color when mouse is not over
var LowSubBgColor='4B4B4B'; // Background color when mouse is not over on subs
var HighBgColor='969696'; // Background color when mouse is over
var HighSubBgColor='969696'; // Background color when mouse is over on subs
var FontLowColor='000000'; // Font color when mouse is not over
var FontSubLowColor='000000'; // Font color subs when mouse is not over
var FontHighColor='2D2D2D'; // Font color when mouse is over
var FontSubHighColor='2D2D2D'; // Font color subs when mouse is over
var BorderColor='333399'; // Border color
var BorderSubColor='333399'; // Border color for subs
var BorderWidth=3; // Border width
var BorderBtwnElmnts=1; // Border between elements 1 or 0
var FontFamily="Tahoma, Verdana, Arial" // Font family menu items
var FontSize=10; // Font size menu items
var FontBold=1; // Bold menu items 1 or 0
var FontItalic=0; // Italic menu items 1 or 0
var MenuTextCentered='center'; // Item text position 'left', 'center' or 'right'
var MenuCentered='center'; // Menu horizontal position 'left', 'center' or 'right'
var MenuVerticalCentered='top'; // Menu vertical position 'top', 'middle','bottom' or static
var ChildOverlap=.2; // horizontal overlap child/ parent
var ChildVerticalOverlap=.2; // vertical overlap child/ parent
var StartTop=6; // Menu offset x coordinate
var StartLeft=6; // Menu offset y coordinate
var VerCorrect=0; // Multiple frames y correction
var HorCorrect=0; // Multiple frames x correction
var LeftPaddng=3; // Left padding
var TopPaddng=3; // Top padding
var FirstLineHorizontal=1; // SET TO 1 FOR HORIZONTAL MENU, 0 FOR VERTICAL
var MenuFramesVertical=1; // Frames in cols or rows 1 or 0
var DissapearDelay=1000; // delay before menu folds in
var TakeOverBgColor=1; // Menu frame takes over background color subitem frame
var FirstLineFrame='navig'; // Frame where first level appears
var SecLineFrame='space'; // Frame where sub levels appear
var DocTargetFrame='space'; // Frame where target documents appear
var TargetLoc=''; // span id for relative positioning
var HideTop=0; // Hide first level when loading new document 1 or 0
var MenuWrap=1; // enables/ disables menu wrap 1 or 0
var RightToLeft=0; // enables/ disables right to left unfold 1 or 0
var UnfoldsOnClick=0; // Level 1 unfolds onclick/ onmouseover
var WebMasterCheck=0; // menu tree checking on or off 1 or 0
var ShowArrow=1; // Uses arrow gifs when 1
var KeepHilite=1; // Keep selected path highligthed
var Arrws=['tridark.gif',5,10,'tridarkdown.gif',10,5,'tridarkleft.gif',5,10]; // Arrow source, width and height


/***********************************************************************
DO NOT EDIT ANYTHING BELOW THIS LINE - IT WILL BREAK THE SCRIPT !
***********************************************************************/

var AgntUsr=navigator.userAgent.toLowerCase();
var DomYes=document.getElementById?1:0;
var NavYes=AgntUsr.indexOf('mozilla')!=-1&&AgntUsr.indexOf('compatible')==-1?1:0;
var ExpYes=AgntUsr.indexOf('msie')!=-1?1:0;
var Opr=AgntUsr.indexOf('opera')!=-1?1:0;
var Opr6orless=window.opera && navigator.userAgent.search(/opera.[1-6]/i)!=-1 //DynamicDrive.com added code
var DomNav=DomYes&&NavYes?1:0;
var DomExp=DomYes&&ExpYes?1:0;
var Nav4=NavYes&&!DomYes&&document.layers?1:0;
var Exp4=ExpYes&&!DomYes&&document.all?1:0;
var PosStrt=(NavYes||ExpYes)&&!Opr6orless?1:0;
var FrstLoc,ScLoc,DcLoc;
var ScWinWdth,ScWinHght,FrstWinWdth,FrstWinHght;
var ScLdAgainWin;
var FirstColPos,SecColPos,DocColPos;
var RcrsLvl=0;
var FrstCreat=1,Loadd=0,Creatd=0,IniFlg,AcrssFrms=1;
var FrstCntnr=null,CurrntOvr=null,CloseTmr=null;
var CntrTxt,TxtClose,ImgStr;
var Ztop=100;
var ShwFlg=0;
var M_StrtTp=StartTop,M_StrtLft=StartLeft;
var StaticPos=0;
var LftXtra=DomNav&&!Opr?LeftPaddng:0; //Changed for Opera
var TpXtra=DomNav?TopPaddng:0;
var M_Hide=Nav4?'hide':'hidden';
var M_Show=Nav4?'show':'visible';
var Par=parent.frames[0]&&FirstLineFrame!=SecLineFrame?parent:window;
var Doc=Par.document;
var Bod=Doc.body;
var Trigger=NavYes&&!Opr?Par:Bod; //Changed for Opera

-=<>=-
 
 http://www.zoldixsava.net/frame.html
InterlinkModule said:
The frame location should be related to the var DocTargetFrame

Indeed it probably should.

InterlinkModele said:
I have a two frame page, as follows:

Code:
<frameset rows="10%,*" border="0">
<frame name="darkness" src="frame.html" marginwidth="10" marginheight="10" scrolling="auto" frameborder="0" noresize>
<frame name="dissolution" src="dissolution.html" marginwidth="10" marginheight="10" scrolling="no" frameborder="0">
</frameset>

Code:
var DocTargetFrame='space';  // Frame where target documents appear

If you know that the [tt]DocTargetFrame[/tt] variable should somehow be related to the frame you want the content to be shown in, why would you set it to something that isn't the name of any of your frames?

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]

Webflo
 
Good question. :) I saw the lines of code you pointed out, and just figured it's supposed to be set to "space", and then it is somehow changed by the Javascript code in the function "GoTo". I didn't think the solution could possibly be something so simple....thanks much, I will go try it now. :)

-=<>=-
 
Hmmm...it still didn't work. It loads the links in the menu frame while the second frame remains unchanged. I even went so far as to change these vars too:

var FirstLineFrame='navig'; // Frame where first level appears
var SecLineFrame='space'; // Frame where sub levels appear

...to match my frameset just to see it would do anything, but gave the same result. Any other ideas? I've also been testing the so called "downloadable scripts" and they are even more difficult to get to do what I want. It's been awhile since I've done anything with raw code...

-=<>=-
 
YOU DON'T HAVE A FRAME CALLED "SPACE" OR ONE CALLED "NAVIG"!!!

Why are you setting these variables to things that bear absolutely no resemblance to what you've defined in your frameset?

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]

Webflo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top