PDA

View Full Version : AnyLink Drop Down Menu: links in new window?



bizy
11-19-2007, 10:13 PM
1) Script Title: AnyLink Drop Down Menu (onMouseover)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/dropmenuindex.htm

3) Describe problem: Everything works fine, but how can I have the links opened in a new browser window?
(Please, be very explicit in your answer, as I only know how to 'copy/paste' Javascript)

Thanks for any reply!

molendijk
11-19-2007, 11:12 PM
Put:
<base target="_new">
just below <html> (beginning of page).

Arie Molendijk.

bizy
11-19-2007, 11:27 PM
Well, never heard about this, but... it works!
Disadvantage: ALL links are now placed in a new window (even the anchors) - I don't know if there is a solution to that?
In other words: can this line be added somewhere in the javascript code? (or some other change?)

Thanks for your help!

molendijk
11-20-2007, 10:30 AM
If you want to treat links individually, leave out the 'base target line'.
Somewhere in your file you have links like:

//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="http://www.javascriptkit.com">JavaScript Kit</a>'
menu1[1]='<a href="http://www.freewarejava.com">Freewarejava.com</a>'
menu1[2]='<a href="http://codingforums.com">Coding Forums</a>'
menu1[3]='<a href="http://www.cssdrive.com">CSS Drive</a>'
etc.

If you want to open, say, the first item and the third item in a new window, replace the preceding lines with:
//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="http://www.javascriptkit.com" target="_new">JavaScript Kit</a>'
menu1[1]='<a href="http://www.freewarejava.com">Freewarejava.com</a>'
menu1[2]='<a href="http://codingforums.com" target="_new">Coding Forums</a>'
menu1[3]='<a href="http://www.cssdrive.com">CSS Drive</a>'

bizy
11-20-2007, 06:36 PM
Thank you!

This can surely do. I'd still like to ask: is there a way to have all links of all menus opened in a new window, excluding all other links on the page (including anchors)?

molendijk
11-20-2007, 07:50 PM
... is there a way to have all links of all menus opened in a new window, excluding all other links on the page (including anchors)?

I think so, but this would make things more complicated than simply having to add ' target="_new" '.

Arie M.