Javascript and frames (Full Version)

All Forums >> [Web Development] >> General Web Development



Message


puiwaihin -> Javascript and frames (3/15/2001 17:05:00)

I'm trying to get a script to create a hierarchial menu. The script works fine, but unfortunately it doesn't seem to be compatible with frames.

The menu appears but is cut off by the end of the frameset.

This part of the script goes in the <head> section:

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
No3 = (parseInt(navigator.appVersion) > 3) ? 1:0;
layer = (document.all && No3) ? "document.all['L'+menu].style" : (document.layers && No3) ? "document.layers['L'+menu]" : 0;
var timer;

function Show() { if(layer) {
if(timer) clearTimeout(timer);
for(menu=0; menu<Layer.length; menu++) { if(Layer[menu]) { eval(layer).visibility = "hidden"; } }
for(i=0; i<arguments.length; i++) { menu=arguments; eval(layer).visibility = "visible"; }
} }
function Hide() { timer = setTimeout("Show()", 500); }
//-->
</SCRIPT>

This part goes into the <Body> part of my HTML document:

<SCRIPT LANGUAGE="JavaScript">
<!--

//////////////////////////////////////////////////////

hovercolor = "#BBBBBB"; // color name/code
bgcolor = "#DDDDDD"; // color name/code
background = ""; // picture url

menu_border = 1; // IE only
border_color = "#000000"; // IE only

arrow_pic = "script740849_0_2.gif"; // url of arrow picture for submenus

//////////////////////////////////////////////////////


if(document.all) { if(!background) { background=bgcolor; } else { background = "url("+background+")"; } }

function LayerSpecs(Left,Top,Width) { if(No3) {
if(document.all) { Top+=7; Left+=2; Width-=6; }
this.left = Left;
this.top = Top;
this.info = "";
T=0;
for(i=3; i<arguments.length; i++) {
if(document.all) { this.info += "<TR><TD WIDTH="+Width+" onMouseOver='this.bgColor=\""+hovercolor+"\"' onMouseOut='this.bgColor=\"\"'>"+arguments+"</TD></TR>"; }
else { this.info += "<LAYER onMouseOver='this.bgColor=\""+hovercolor+"\"' onMouseOut='this.bgColor=\""+bgcolor+"\"' WIDTH="+Width+" POSITION=RELATIVE TOP="+T+"> "+arguments+"</LAYER>"; }
T+=20;
}
} }

Layer = new Array();
arrow = "<IMG SRC='"+arrow_pic+"' WIDTH=6 HEIGHT=10 BORDER=0 ALT=''>";


//////////////////////////////////////////////

/* Create Your layers below by typing:
Layer[incrementing number] = new LayerSpecs(Left Position, Top Position, Width, List of Links Seperated by Commas)
If a layer has a sublayer, add onMouseOver="Show(Layer Number to Open, Current Layer, Any Layers Opened before the current layer (seperated by commas)
*/

Layer[1] = new LayerSpecs(121,27,110,
'<A HREF="http://www.byu.edu" onMouseOver="Show(4,1)">Layer 1</A> '+arrow,
'<A HREF="http://www.javascripts.com" onMouseOver="Show(1)">Javascripts.com</A> ',
'<A HREF="http://www.javascripts.com" onMouseOver="Show(1)">Javascripts.com</A> ',
'<A HREF="http://www.javascripts.com" onMouseOver="Show(1)">Javascripts.com</A> ',
'<A HREF="http://www.javascripts.com" onMouseOver="Show(1)">Javascripts.com</A> '
);


(repeated code cut for brevity)


Layer[8] = new LayerSpecs(241,120,180,
'<A HREF="http://www.javascripts.com">Layer 8</A> ',
'<A HREF="http://www.javascripts.com">Javascripts.com</A> ',
'<A HREF="http://www.javascripts.com">Javascripts.com</A> ',
'<A HREF="http://www.javascripts.com">Javascripts.com</A> ',
'<A HREF="http://www.javascripts.com">Javascripts.com</A> '
);


////////////////////////////////////////////////////////////////

j = (Layer[0]) ? 0:1;

for(i=j; i<Layer.length; i++) {
if(document.all && No3) { document.write("<SPAN onMouseOver='clearTimeout(timer)' onMouseOut='Hide("+i+")' ID='L"+i+"' STYLE='position:absolute; visibility:hidden; background:"+background+"; top:"+Layer.top+"; left:"+Layer.left+";'><TABLE STYLE='border:solid "+menu_border+" "+border_color+"'>"+Layer.info+"</TABLE></SPAN>"); }
else if(document.layers && No3) { document.write("<LAYER onMouseOver='clearTimeout(timer)' onMouseOut='Hide("+i+")' ID='L"+i+"' POSITION=ABSOLUTE VISIBILITY=HIDDEN BGCOLOR='"+bgcolor+"' BACKGROUND='"+background+"' TOP="+Layer.top+" LEFT="+Layer.left+">"+Layer.info+"</LAYER>"); }
}

if(document.all) { document.all["menubar"].style.visibility = "visible"; }
else if(document.layers) { document.layers["menubar"].visibility = "visible"; }

// -->
</SCRIPT>


Can anyone help with this?


[This message has been edited by puiwaihin (edited 03-15-2001).]





Dixiedi -> RE: Javascript and frames (3/15/2001 18:41:00)

If you mean the bottom links on your menu do not show up, all you need to do is give your frame scrolling ability.

If you mean the fly out gets cut off on the side of the frame, there is nothing you cn do about it. The fly out part flies out on the page it is installed on. You have cut that page off with the frame.

Any hierachy type menu you use will have to be the kind that opens straight down.





puiwaihin -> RE: Javascript and frames (3/15/2001 19:12:00)

That was the answer I didn't want, but thanks for answering me anyway =P




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875