Change map overlay function to open link in new window

I inherited a google map overlay that displays station icons with station name labels.  If you click on the icon, you get another label with more station information and a link to the weather station condition page. Unfortunately, the link opens in the same window as the map: to return to the map, you have to press the "back button" key in the browser, which is not user-friendly.  

I want the link to open to a new window (preferably) or tab, whatever google maps supports. Their reference page at  http://code.google.com/apis/maps/documentation/reference.html probably answers the question but I can't find a way to apply the code in a way that works.  The function below is the one I'm trying to change.  The javascript file that it belongs to is attached - it's one of several files that we're using to make this work, but I don't think the others relate to the problem (the map and overlays show up in the html page; the labels correctly import from an xml file; the links I'm trying to open from the map labels are pre-existing html and shtml pages that reside on our server).
function stationMarker(station_name, point, icon, link) {
	var marker = new GMarker(point, icon);
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml("Station Name: "+station_name+"<br>Location: Lat "+point.lat()+" Lng "+point.lng()+"<br>Link: <a href=\"http://"+link+"\">www<a/>");
	});
	return marker;
}

Open in new window

gmap2.txt
sara_bellumAsked:
Who is Participating?
 
Michel PlungjanConnect With a Mentor IT ExpertCommented:
This will handle popup blockers too:

<a href=\"http://"+link+"\" target=\"_blank\" onClick=\"var w=window.open(this.href,this.target,'width=300,heigth=400'); return (w)?false:true;\">www</a>"

Open in new window

0
 
sara_bellumAuthor Commented:
I should mention that this problem exists for all browsers and platforms that I've tested (Linux and Windows clients with Firefox and IE, with preferences/options set to open new links in new tabs and/or windows)
0
 
Michel PlungjanIT ExpertCommented:
You mean

Link: <a href=\"http://"+link+"\" target=\"_blank\">www</a>"

Note I changed the wrong <a/> too
0
 
sara_bellumAuthor Commented:
Brilliant! I had tried the same approach earlier but made mistakes, and failed to catch the closing href error too...is there a way to set the window size so that it appears to pop up?  I know this is beyond the scope of my original question but thought I'd try my luck :)
0
 
sara_bellumAuthor Commented:
Thank you so much!! On to the drudgery of checking lat/longs...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.