开发者

Calling a JavaScript function within an InfoWindow (Google Maps)

I'm having an issue calling a javascript function within a Google Maps InfoWindow. The relevant code is below:

<script type="text/javascript">
<!--
/* … unnecessary code */

function closeTo(url_slug) {
    parent.url_slug = url_slug;
    parent.$.fancybox.close();
}

var contentString = '<a href="javascript:closeTo(\'foo\');">close</a>';

var callout = new google.maps.InfoWindow({
    content:contentString
});

//-->
</script>

The above example results in a blank map. However, if I change the content string to this:

var contentString = '<a href="#">close</a>';

It works just fine. Also, I'v开发者_StackOverflow中文版e called the function from a link on the page (not an InfoWindow) and it works as well. The general idea is to respond to a click in an InfoWindow, close the fancybox, and redirect to the location provided. So, my question is this. How do I call a function within an InfoWindow?


There is nothing inherently wrong with calling a javascript function from an infoWindow. I suggest you check the JavaScript error log and try and track down what is happening once closeTo is called.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜