Google API 在 IE7和firefox中document.createTextNode中文字体兼容的问题!

学习google api 开发的时候发现有个实例有点问题。


打开信息浮窗
http://www.google.com/intl/zh-CN/apis/maps/documentation/index.html#Opening_an_Info_Window
http://www.step1.cn/GoogleApi/map2/5.infowindow.html
http://www.step1.cn/GoogleApi/map2/documentation.htm#Opening_an_Info_Window



以下是我部分代码


<meta http-equiv="content-type" content="text/html; charset=GB2312" />
指示浏览器使用中文字符集为GB2312


var map = new GMap2(document.getElementById("map"));
map.setCenter(
new GLatLng(39.917116.397), 14);
map.openInfoWindow(map.getCenter(),
                   document.createTextNode(
"Hello, world"));
最开始的时候是按照http://www.google.com/intl/zh-CN/apis/maps/documentation/index.html#Opening_an_Info_Window中提供的代码在IE7下面和firefox下面运行都没有问题。


var map = new GMap2(document.getElementById("map"));
map.setCenter(
new GLatLng(39.917116.397), 14);
map.openInfoWindow(map.getCenter(),
                       document.createTextNode(
"你好,中国"));
然后我把"Hello,world"替换成为“你好,中国”这个时候问题就来了,在firefox下面能够正常运行,但是在IE7下面就不能运行。说明google 的main.js中的API在ie下可能支持不是很好.



var map = new GMap2(document.getElementById("map"));
map.setCenter(
new GLatLng(39.917116.397), 14);
var newNode = document.createElement('a'); 
var txtNode 
= document.createTextNode('你好,中国'); 
newNode.appendChild(txtNode); 
map.openInfoWindow(map.getCenter(),newNode);
后来在网上搜索了一些资料用以上的代码替换就可以解决问题。但是我也不知道是为什么!
期待高手解答。
posted @ 2008-01-06 11:32  观我生,君子无咎  阅读(864)  评论(0)    收藏  举报