开发者

InfoWindow: Setting lang attribute inside div tag not working

I am trying to set language attribute to some value other than "en" [say "ko"] inside a div tag. The content string that I create in this way is being used to set the InfoWindow's setContent(). Unfortunately, I continue to see the text in English rather than the language value I have defined. Here are the relevant pieces of code:

content_string = '<div style="width: 210px; padding-right: 10px" lang="ko" xml:lang="ko">' + biz_name_html + '<br>' + biz_addr + '<br>' + biz_url_html + '<br>' + biz_phone + '<br>' + biz_description + '</div>';

           marker = new google.maps.Marker({
               position: latlng,
               map: map,
               title: biz_name,
               html: content_string,
               icon: new google.maps.MarkerImage(marker_icon_url)
           });
        开发者_C百科   google.maps.event.addListener(marker, 'click', function() {
               info_window.setContent(this.html);
               info_window.open(map, this);
           });


Defining the lang attribute will not convert text to a specified language. From the htmlhelp.com

The LANG attribute specifies the language of an element's attribute values and its content, including all contained elements that do not specify their own LANG attribute. While the LANG attribute is not widely supported, its use may help search engines index a document by its language while allowing speech synthesizers to use language-dependent pronunciation rules. As well, visual browsers can use the language's proper quotation marks when rendering the Q element.

Actually putting Korean into your div tag (or using the character codes) will display correctly, such as :

content_string = '<div style="width: 210px; padding-right: 10px" lang="ko" xml:lang="ko">&#44396;&#44208; &#21475;&#35363;</div>';
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜