Click to See Complete Forum and Search --> : Really stupid question here.


Naild
03-13-2005, 10:01 PM
How can I get the links in this script to open in a new window? Any help would be appriciated. Thank you.


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

/*
Static menu script (By maXimus, maximus@nsimail.com, http://absolutegb.com/maximus/)
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
*/

//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();

//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";

for (i=0;i<=menui.length-1;i++)
if (ie4||ns6) {document.write('<TR><TD BORDERCOLOR="white" ONCLICK="location=\''+menul[i]+'\'" onmouseover="className=\'menuh\'" onMouseout="className=\'menu\'"><CENTER><FONT>'+menui[i]+'</FONT></TD></TR>')}
else if (ns4){document.write('<TR><TD BGCOLOR="white"><ILAYER><LAYER width="'+menuwidth+'" onmouseover="bgColor=\'yellow\'" onmouseout="bgColor=\'white\'"><CENTER><A HREF="'+menul[i]+'" class=menulinks>'+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>

Jona
03-13-2005, 10:56 PM
else if (ns4){document.write('<TR><TD BGCOLOR="white"><ILAYER><LAYER width="'+menuwidth+'" onmouseover="bgColor='yellow'" onmouseout="bgColor='white'"><CENTER><A HREF="'+menul[i]+'" target="_blank" class=menulinks>'+menui[i]+'</A></CENTER></LAYER></ILAYER></TD></TR>')}

Naild
03-14-2005, 08:36 PM
Thank you for taking the time to help me Jona, but it didn't work sorry to say. The entire menu just disappeared.:(

I only replaced that part of the script too. I think I'm going to throw this computer out a window. LOL

Any other idea's?

Jona
03-14-2005, 08:37 PM
else if (ns4){document.write('<TR><TD BGCOLOR="white"><ILAYER><LAYER width="'+menuwidth+'" onmouseover="bgColor=\'yellow\'" onmouseout="bgColor=\'white\'"><CENTER><A HREF="'+menul[i]+'" target="_blank" class="menulinks">'+menui[i]+'</A></CENTER></LAYER></ILAYER></TD></TR>')}

Naild
03-15-2005, 01:23 PM
Thank you for all your effort Jona, but it still didn't work. The menu did not display at all. However, someone else fixed it for me and I thought I would write you back so you know how it was fixed for future reference. Again, thank you very much for trying and God bless.


else if (ns4){document.write('<TR><TD BGCOLOR="white"><ILAYER><LAYER width="'+menuwidth+'" onmouseover="bgColor=\'yellow\'" onmouseout="bgColor=\'white\'"><CENTER><A HREF="'+menul[i]+'" class=menulinks target="_blank">'+menui[i]+'</A></CENTER></LAYER></ILAYER></TD></TR>')}


The solution was:
class=menulinks target="_blank">

Jona
03-15-2005, 01:25 PM
The backslahes were removed from my post otherwise I'm certain it would have worked. The order of the attributes in an element hardly affect its appearance.

Pittimann
03-15-2005, 01:32 PM
Hi Jona!

I'd say the problem was 'document.layers'; I am quite sure, Naild - like quite a number of people - is not using NS4. I suspect, this (http://www.webdeveloper.com/forum/showthread.php?s=&postid=334012#post334012) contributed to the solution.

The menu in question is one of the worst I've ever seen; hope I pointed that out understandably enough in the DHTML forum's thread.

Cheers - Pit

Jona
03-15-2005, 03:55 PM
Thanks for clearing that up, Pitt. Cheers! :)

Pittimann
03-15-2005, 03:57 PM
Hi!

Actually, it was Naild clearing it up. :p

Regards - Pit