PDA

View Full Version : Static Menu Script II question



|-Iceman-|
01-19-2005, 07:38 PM
Is there a way to open one link in a new window and the rest in a frame? My friend told me that there wasn't, but I wanted to get a second opinion.

cr3ative
01-19-2005, 09:19 PM
M'kay.

This works, but it will ignore the cell background colour as defined by the stylesheet in the HEAD section. I have highlighted in bold where you need to change the colour to manually set this.

The array cr3mod can be used to target frames.
The first link opens in a new window, and the rest open in a frame called "framename", if that frame is avaliable.



<SCRIPT Language="Javascript1.2">
<!--

/*
Static menu script II (By maXimus, maximus@nsimail.com, http://maximus.ravecore.com/)
Modified slightly/ permission granted to Dynamic Drive to feature script in archive
For full source, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
Modified again by cr3ative to allow link targeting
*/

//configure below variable for menu width, position on page
var menuwidth=110
var offsetleft=10
var offsettop=90

var ns4=document.layers?1:0
var ie4=document.all?1:0
var ns6=document.getElementById&&!document.all?1:0

function makeStatic() {
if (ie4) {object1.style.pixelTop=document.body.scrollTop+offsettop}
else if (ns6) {document.getElementById("object1").style.top=window.pageYOffset+offsettop}
else if (ns4) {eval(document.object1.top=eval(window.pageYOffset+offsettop));}
setTimeout("makeStatic()",0);
}

if (ie4||ns6) {document.write('<span ALIGN="CENTER" ID="object1" STYLE="Position:absolute; Top:20; Left:'+offsetleft+';

Z-Index:5;cursor:hand;background-color:black;"><TABLE BORDER="1" width="'+menuwidth+'" CELLPADDING="0" CELLSPACING="0"

BORDERCOLOR="black" bgcolor="white">')}
else if (ns4){ document.write('<LAYER top="20" name="object1" left="'+offsetleft+'" BGCOLOR=black><TABLE BORDER="0"

CELLPADDING="0" CELLSPACING="1"><TR><TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" width="'+menuwidth+'">')}

if (ie4||ns6||ns4)
document.write('<TR><TD BGCOLOR="#3399FF" BORDERCOLORDARK="#99CCFF" BORDERCOLORLIGHT="#003399"><P

ALIGN=CENTER><FONT SIZE="4" FACE=ARIAL>Menu</FONT></TD></TR>')

var menui = new Array();
var menul = new Array();
var cr3mod = new Array();

//configure below for menu items. Extend list as desired

menui[0]="Dynamic Drive";
menui[1]="What\'s New?";
menui[2]="What\'s Hot?";
menui[3]="Message Forum";
menui[4]="FAQs";
menui[5]="Submit Script";
menui[6]="Link to us";
menui[7]="Email us";

menul[0]="http://dynamicdrive.com";
menul[1]="http://dynamicdrive.com/new.htm";
menul[2]="http://dynamicdrive.com/hot.htm";
menul[3]="http://wsabstract.com/cgi-bin/Ultimate.cgi";
menul[4]="http://dynamicdrive.com/faqs.htm";
menul[5]="http://dynamicdrive.com/submit.htm";
menul[6]="http://dynamicdrive.com/link.htm";
menul[7]="http://dynamicdrive.com/contact.htm";

cr3mod[0]="_blank";
cr3mod[1]="framename";
cr3mod[2]="framename";
cr3mod[3]="framename";
cr3mod[4]="framename";
cr3mod[5]="framename";
cr3mod[6]="framename";
cr3mod[7]="framename";

for (i=0;i<=menui.length-1;i++)
document.write('<TR><TD BGCOLOR="white"><ILAYER><LAYER width="'+menuwidth+'" onmouseover="bgColor=\'yellow\'"

onmouseout="bgColor=\'white\'"><CENTER><A HREF="'+menul[i]+'" class=menulinks

target="'+cr3mod[i]+'">'+menui[i]+'</A></CENTER></LAYER></ILAYER></TD></TR>')

if (ie4||ns6) {document.write('</TABLE></span>')}
else if (ns4){document.write('</TABLE></TD></TR></TABLE></LAYER>')}

function menu3(){
if (ns6||ie4||ns4)
makeStatic()
}

window.onload=menu3

//-->
</SCRIPT>

cr3ative

|-Iceman-|
01-20-2005, 05:31 AM
now my menu doesn't even show up.

cr3ative
01-20-2005, 10:12 AM
Have you got a link to the page you are using (which shows no menu)?
Confusing.

cr3ative

|-Iceman-|
01-20-2005, 02:56 PM
all i did was copy and paste your code i was gonna cutomize it later.