View Full Version : How do I make some links open in a new browser window?

03-26-2007, 02:02 PM
1) Script Title: Ger Versluis 2000 version 1.0

2) Script URL (on DD): www.dynamicdrive.com

3) Describe problem: I need for some of my links within my menu to open up in a new window browser so the user doesn't have to arrow back to my site when a file opens like for instance this code

Menu3_11=new Array("Acquisition Planning Guide","http://www.logcom.usmc.mil/contracts/files/ACQ_PLAN.pdf",0,14,200)

; . I need to know what code I need to use and where in the code of the menu would it go.

Here is the menu script:

//(c) Ger Versluis 2000 version 1.0, 1 november 2000

var NoOffFirstLineMenus=3; //set number of main menu items
var LowBgColor='#FFFFFF';
var HighBgColor='#FFFFCC';
var FontLowColor='0000FF';
var FontHighColor='black';
var BorderColor='CE0000';
var BorderWidth=1;
var BorderBtwnElmnts=1;
var FontFamily="arial"
var FontSize=8;
var FontBold=0;
var FontItalic=0;
var MenuTextCentered=0;
var MenuCentered='left';
var MenuVerticalCentered='top';
var ChildOverlap=.1;
var ChildVerticalOverlap=.1;
var StartTop=137; //set vertical offset
var StartLeft=207; //set horizontal offset
var VerCorrect=0;
var HorCorrect=0;
var LeftPaddng=3;
var TopPaddng=0;
var FirstLineHorizontal=1; //set menu layout (1=horizontal, 0=vertical)
var MenuFramesVertical=1;
var DissapearDelay=500;
var TakeOverBgColor=1;
var FirstLineFrame='navig';
var SecLineFrame='space';
var DocTargetFrame='space';
var WebMasterCheck=0;

//Menux=new Array("text to show","Link",No of sub elements,element height,element width);
//see accompanying "config.htm" file for more information on structure of menus

<!--First Menu-->
Menu1=new Array("About Us","",1,14,130);
Menu1_1=new Array("Points of Contact","/contracts/poc.asp",0,14,150);

<!--Second Menu-->
Menu2=new Array("Contractors","",5,100,220);
Menu2_1=new Array("Doing Business with the Government","/contracts/bisgov.asp",0,14,250);
Menu2_2=new Array("Small Business Program Office","http://www.logcom.usmc.mil/sbpo/default.asp",0);
Menu2_3=new Array("Solicitations > $25000","/contracts/solicitations.asp",0);
Menu2_4=new Array("Invoicing and the Paying Office","/contracts/invoicing.asp",0);
Menu2_5=new Array("Drawings","http://www.logcom.usmc.mil/contracts/solicit/",0);

<!--Third Menu-->
Menu3=new Array("Policy","",24,100,220);
Menu3_1=new Array("FAR","http://farsite.hill.af.mil/",0,14,200);
Menu3_2=new Array("DFARS","http://farsite.hill.af.mil",0,14,200);
Menu3_3=new Array("NMCARS/NMCAG","http://www.abm.rda.hq.navy.mil/navyaos/content/view/full/3464",0,14,200);
Menu3_4=new Array("MAPS","http://www.logcom.usmc.mil/contracts/files/MAPS Dec 2004 23 Dec 04 RO.pdf",0,14,200);
Menu3_5=new Array("Marine Corps Orders/Base Orders","http://www.ala.usmc.mil/bo/",0,14,200);
Menu3_6=new Array("Local Instructions","",2,14,200);
Menu3_6_1=new Array("CPARS 04-01","http://www.logcom.usmc.mil/contracts/files/CPARS Policy 04-01.pdf",0,14,200);
Menu3_6_2=new Array("Instructions for loading drawings","http://www.logcom.usmc.mil/contracts/files/drawings.pdf",0,14,200);
Menu3_7=new Array("NAVSUPINST 4200.85D","http://www.logcom.usmc.mil/contracts/files/NAVSUPINST 4200.85D.pdf",0,14,200);
Menu3_8=new Array("DoN Policy Memo","",1,14,200);
Menu3_8_1=new Array("Food/Conference Fees","http://www.logcom.usmc.mil/contracts/files/Appropriated Funds to Purchase Food for Events.pdf",0,14,150);
Menu3_9=new Array("CG Decisions","http://www.gao.gov/decisions/appro/306050.htm",0,14,200);
Menu3_10=new Array("MCO Intl Mgmt Control","http://www.logcom.usmc.mil/contracts/files/INTERNAL MANAGEMENT CONTROL PROGRAM MANUAL _05200_2A1.pdf",0,14,200);
Menu3_11=new Array("Acquisition Planning Guide","http://www.logcom.usmc.mil/contracts/files/ACQ_PLAN.pdf",0,14,200);
Menu3_12=new Array("Performance Based Acquisition","",2,14,200);
Menu3_12_1=new Array("PBA Memo","http://www.acq.osd.mil/dpap/policy/policyvault/2006-1651-DPAP.pdf",0,14,100);
Menu3_12_2=new Array("Acq of Services Memo","http://www.whitehouse.gov/omb/procurement/pbsa/pba_2006_memo.pdf ",0,14,100);
Menu3_13=new Array("COR Instruction","http://www.logcom.usmc.mil/contracts/files/NAVSUP COR INST.pdf",0,14,200);
Menu3_14=new Array("NAVSUP Office Supplies","/contracts/navsup.asp",0,14,200);
Menu3_15=new Array("Proper Use of Non-DoD Contracts","",4,14,200);
Menu3_15_1=new Array("Policy","http://www.logcom.usmc.mil/contracts/nondod.asp",0,14,100);
Menu3_15_2=new Array("MAPS","http://www.logcom.usmc.mil/contracts/files/Non-DoD ACQUISITION PROCEDURES.pdf",0,14,100);
Menu3_15_3=new Array("DPAP Website","http://www.acq.osd.mil/dpap/specificpolicy/index.htm",0,14,100);
Menu3_15_4=new Array("Contracts Policy","http://www.logcom.usmc.mil/contracts/files/Contracts Policy.pdf",0,14,100);
Menu3_16=new Array("CHINFO","/contracts/CHINFO.asp",0,14,200);
Menu3_17=new Array("CPARS Slides","http://www.logcom.usmc.mil/contracts/files/CPARS overview.pps",0,14,200);
Menu3_18=new Array("FPDS-NG","",4,14,150);
Menu3_18_1=new Array("Helpful Tips","http://www.logcom.usmc.mil/contracts/files/FPDS-NG 10-03-2006.pdf",0,14,200);
Menu3_18_2=new Array("Lessons Learned & Instructions","http://www.logcom.usmc.mil/contracts/files/FPDS Lessons Learned.pdf",0,14,200);
Menu3_18_3=new Array("User's Guide","http://www.logcom.usmc.mil/contracts/files/APO FPDS-NG USERS GUIDE.pdf",0,14,200);
Menu3_18_4=new Array("Training Slides","http://www.logcom.usmc.mil/contracts/files/FPDS-NG Functional Training 24 Oct 06.ppt",0,14,200);
Menu3_19=new Array("JWOD Guide","http://www.logcom.usmc.mil/contracts/files/JWOD20buyers20guide.pdf",0,14,200);
Menu3_20=new Array("MOPAS","http://www.logcom.usmc.mil/contracts/files/CMC Ltr 4200 LB 25 May 04.pdf",0,14,200);
Menu3_21=new Array("A-76","",2,14,150);
Menu3_21_1=new Array("ASN Memo","http://www.logcom.usmc.mil/contracts/files/ASN Memo.pdf",0,14,200);
Menu3_21_2=new Array("Competitive Sourcing and Privatization","http://www.logcom.usmc.mil/contracts/files/155 Chp 15 Competitive Sourcing.pdf",0,14,200);
Menu3_22=new Array("RFID","",6,14,150);
Menu3_22_1=new Array("RFID slides May 2006","http://www.logcom.usmc.mil/contracts/files/RFID June 2006.ppt",0,14,150);
Menu3_22_2=new Array("DFARS 211.275-2","http://www.logcom.usmc.mil/contracts/files/DFARS 211.275-2.pdf",0,14,150);
Menu3_22_3=new Array("DFARS 252.211-7006","http://www.logcom.usmc.mil/contracts/files/DFARS 252.211-7006.pdf",0,14,150);
Menu3_22_4=new Array("RFID slides Dec 2005","http://www.logcom.usmc.mil/contracts/files/RFID webinar.ppt",0,14,150);
Menu3_22_5=new Array("RFID website","http://www.acq.osd.mil/log/rfid/index.htm",0,14,150);
Menu3_22_6=new Array("Class of Supply Lookup","http://www.acq.osd.mil/log/rfid/Class_of_supply_lookup_tool.htm",0,14,150);
Menu3_23=new Array("UID","",1,14,200);
Menu3_23_1=new Array("DPAP","http://www.acq.osd.mil/dpap/UID/",0,14,50);
Menu3_24=new Array("GME","",1,14,200);
Menu3_24_1=new Array("Policy","http://www.logcom.usmc.mil/contracts/files/GME Purchase & Lease Policy.pdf",0,14,50);

03-26-2007, 02:05 PM
That's not the entire code. Also, if this is a script here on DD, please include the actual link to the page (not a link to the entire site). Hope this helps.

03-26-2007, 02:07 PM
It's very hard to read a script posted just as text.

Please use [code]...p/code] tags to seperate it.

Also, if this is a script on DD, then link directly to that script so we can see how it works in the first place to be help.

What you posted above is not complete either, and not related to how it opens in a new window (or not).
The code, as I said in the other thread, that generates the link must be changed, not the code that sets a value as the url for the link to be used later.

The most important question--
do you need to choose invidually which links open in a new window?
Or can they all just open in a new window?

Just link to the Dynamic Drive webpage for the script and we'll take a look.

03-26-2007, 02:11 PM
Actually, just looking at that (without having the rest of the code), I notice that all of the lines like this:

Menu3_11=new Array("Acquisition Planning Guide","http://www.logcom.usmc.mil/contracts/files/ACQ_PLAN.pdf",0,14,200)

have a zero in the array. Try changing that (the part in red) to a 1 and see if that helps. If not, change it back. Hope this helps.

03-26-2007, 02:48 PM
Sorry about that. Here is a link:


My menu works like the link above. I need for select links to open in a new window not all of them. Thank you again and I hope I did this right.


03-26-2007, 02:52 PM
I you are just using that script, simply put the target attribute in the menu array. Use the following as an example:

menu1[0]='<a onclick="window.open(this.href); return false;" href="http://www.javascriptkit.com">JavaScript Kit</a>'

Notice the part in red. Only use that for those links you want to open in a new window.

Hope this helps.

03-27-2007, 04:10 AM


03-27-2007, 03:06 PM
John you are the man! That worked perfectly! Thank you very much! I appreciated big time!


07-09-2007, 06:14 PM
I've read through this thread. I've been looking for a way to have new browser window open on a select link in the hvmenu 5.5. I've tried what you suggested, but since my arrays in 5.5 don't use <a href></a> tags, this isn't working.

would you please code for me what needs to be adjusted in the example below for this one menu item to open in a new browser window:

Menu2=new Array("CALENDAR',"calendar.php',"',0,15,110);

btw, I love this script. it's a snap to use.


07-09-2007, 07:28 PM
I've read through this thread. I've been looking for a way to have new browser window open on a select link in the hvmenu 5.5. I've tried what you suggested, but since my arrays in 5.5 don't use <a href></a> tags, this isn't working.

would you please code for me what needs to be adjusted in the example below for this one menu item to open in a new browser window:

Menu2=new Array("CALENDAR',"calendar.php',"',0,15,110);

btw, I love this script. it's a snap to use.



07-10-2007, 06:42 PM
thank you -- I went to the new posting area and grabbed the code. I'm sure what you have suggested will work eventually. Right now it is not operational and it is commenting out.

I have pasted it in.
I've used it in a clean re-construction.
I've retyped it manually

The ' are changing to " and vice versa.

I've been using this menu for 5 years now and understand it inside and out. I'm using the newest version for Opera now. Who knows, it may just not be my day.

I'll keep messing around before starting over. Thank you again for being so prompt. mean it. LJ