Discussion Locked

window.open

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have written a menu in java script where the link takes you to a web address code as follows:
var MENU_ITEMS =[
["Sports & Leisure", null,
["Bowling clubs", "bowling"],
["Sports clubs", "sportsclubs"],
["Sports centres", window.open("http://www.wirral.gov.uk/ed/sports_centres.htm", "target" ) ],
["Parks", "http://www.wirral.gov.uk/er/"],
["Libraries", "http://www.wirral-libraries.net/" ]

],
I would like the window to open when the link is clicked and not when the index page is loaded of the site. How do I over come the problem?

Cheers

3 replies

by Former member

Instead of
window.open("http://www.wirral.gov.uk/ed/sports_centres.htm ", "target" )
try
"javascript:window.open('http://www.wirral.gov.uk/ed/sports_centres.htm ', 'target' )"

by nicob1981

hi,

the problem lies here: when you create the array in each field it is put exactly what you tell javascript. in the problematic case its the return value of the window.open function - usually a window handle. you have two options to overcome this. first you place handling code for the procedure that is executing the link (as i am assuming that bowling and sportsclubs are no links but parameters for a handling function). The other option is to place the whole term in quotation marks - then it is simply a string. if you want to use it from whitin another script/function there should be a function that executes code within a string. You gotta check here for (eval, or exec - dont remember). the other option is to place it with a preceeding 'javascript:' in a HREF attribute of you link.

Have phun codin

Nico

by sreehari

It seems you're using Tigraa Tree (www.softcomplex.com).

Your problem is not at all clear. Can you elaborate further on this ?

Sreehari.

This discussion is closed to new replies.