1

我試圖將語言屬性設置爲除div標籤內的 「en」[說「ko」]之外的某個值。我以這種方式在 中創建的內容字符串用於設置InfoWindow的setContent()。不幸的是,我繼續看到英文文本,而不是我定義的語言值。 下面是代碼中的相關部分:InfoWindow:在div標籤內部設置lang屬性不起作用

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) 
      }); 
      google.maps.event.addListener(marker, 'click', function() { 
       info_window.setContent(this.html); 
       info_window.open(map, this); 
      }); 

回答

1

定義lang屬性不會文本轉換成指定語言。從htmlhelp.com

lang屬性指定了一個元素的屬性值 其內容的語言,包括所有包含不 指定自己的LANG屬性的元素。儘管LANG屬性不是被廣泛支持,但其使用可以幫助搜索引擎通過其語言索引 文檔,同時允許語音合成器使用與語言相關的發音規則 。同樣,在呈現Q 元素時,視覺瀏覽器可以使用該語言的正確引號。

事實上把韓國到您的div標籤(或使用字符代碼)將正確顯示,如:

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