google map api在ie6中:缺少对象的解决方案

本文介绍了解决Google Maps API在IE6浏览器中出现的“缺少对象”错误的方法。提供了两种解决方案:一是通过修改<meta>标签设置charset为utf-8;二是保留原有charset设置,在<script>标签中添加charset=utf-8属性。
用过google map api的人都应该会注意到,示例的js脚本在FF,opera,...(非ie6的浏览器)都正常.在ie6下会报错:
缺少对象
错误的行号一般都指向GMap2对象创建的行上

解决方案有两种:
1.在meta中指定charset=utf-8,原因大家可以去google中勾一下
2.如果应用中的charset都是非utf-8哪怎么办呢?总不能为了一粒米丢掉所有玉米.方案如下
要在网站中使用map api就要引用一个js文件,我们可以在这想办法,在script的属性中也有一个charset属性,添加它
 <script ... charset="utf-8"></script>

下面是一些示例
用的map key为:t6new.cn的

默认示例(ie下会提示缺少对象)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  5. <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAy_92lh6L5xhcKXiWFze7ahSeyyn5-963h60-vJRKrf4xaRdBuBTmF2UsZnFk8o95hGt2T99GRoVPiA"
  6.       type="text/javascript"></script>
  7. <title>google map demo</title>
  8. <script type="text/javascript">
  9. //<![CDATA[
  10.     var map = null;
  11.     var geocoder = null;
  12.     function initialize() {
  13.       if (GBrowserIsCompatible()) {
  14.         map = new GMap2(document.getElementById("map_canvas"));
  15.         map.setCenter(new GLatLng(37.5429, 121.3776), 13);
  16.         geocoder = new GClientGeocoder();
  17.       }
  18.     }
  19.     function showAddress(address) {
  20.       if (geocoder) {
  21.         geocoder.getLatLng(
  22.           address,
  23.           function(point) {
  24.             if (!point) {
  25.               alert(address + " not found");
  26.             } else {
  27.               map.setCenter(point, 13);
  28.               var marker = new GMarker(point);
  29.               map.addOverlay(marker);
  30.               marker.openInfoWindowHtml(address);
  31.             }
  32.           }
  33.         );
  34.       }
  35.     }
  36. //]]>
  37. </script>
  38. </head>
  39. <body onload="initialize()" onunload="GUnload()">
  40. <input type="text" name="address" size="50" value="烟台市西盛街28号第一大道" onblur="showAddress(this.value);" />
  41. <div id="map_canvas" style="width: 500px; height: 300px"></div>
  42. </body>
  43. </html>
meta示例:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAy_92lh6L5xhcKXiWFze7ahSeyyn5-963h60-vJRKrf4xaRdBuBTmF2UsZnFk8o95hGt2T99GRoVPiA"
  6.       type="text/javascript"></script>
  7. <title>google map demo</title>
  8. <script type="text/javascript">
  9. //<![CDATA[
  10.     var map = null;
  11.     var geocoder = null;
  12.     function initialize() {
  13.       if (GBrowserIsCompatible()) {
  14.         map = new GMap2(document.getElementById("map_canvas"));
  15.         map.setCenter(new GLatLng(37.5429, 121.3776), 13);
  16.         geocoder = new GClientGeocoder();
  17.       }
  18.     }
  19.     function showAddress(address) {
  20.       if (geocoder) {
  21.         geocoder.getLatLng(
  22.           address,
  23.           function(point) {
  24.             if (!point) {
  25.               alert(address + " not found");
  26.             } else {
  27.               map.setCenter(point, 13);
  28.               var marker = new GMarker(point);
  29.               map.addOverlay(marker);
  30.               marker.openInfoWindowHtml(address);
  31.             }
  32.           }
  33.         );
  34.       }
  35.     }
  36. //]]>
  37. </script>
  38. </head>
  39. <body onload="initialize()" onunload="GUnload()">
  40. <input type="text" name="address" size="50" value="烟台市西盛街28号第一大道" onblur="showAddress(this.value);" />
  41. <div id="map_canvas" style="width: 500px; height: 300px"></div>
  42. </body>
  43. </html>

script属性charset示例
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  5. <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAy_92lh6L5xhcKXiWFze7ahSeyyn5-963h60-vJRKrf4xaRdBuBTmF2UsZnFk8o95hGt2T99GRoVPiA"
  6.       type="text/javascript" charset="utf-8"></script>
  7. <title>google map demo</title>
  8. <script type="text/javascript">
  9. //<![CDATA[
  10.     var map = null;
  11.     var geocoder = null;
  12.     function initialize() {
  13.       if (GBrowserIsCompatible()) {
  14.         map = new GMap2(document.getElementById("map_canvas"));
  15.         map.setCenter(new GLatLng(37.5429, 121.3776), 13);
  16.         geocoder = new GClientGeocoder();
  17.       }
  18.     }
  19.     function showAddress(address) {
  20.       if (geocoder) {
  21.         geocoder.getLatLng(
  22.           address,
  23.           function(point) {
  24.             if (!point) {
  25.               alert(address + " not found");
  26.             } else {
  27.               map.setCenter(point, 13);
  28.               var marker = new GMarker(point);
  29.               map.addOverlay(marker);
  30.               marker.openInfoWindowHtml(address);
  31.             }
  32.           }
  33.         );
  34.       }
  35.     }
  36. //]]>
  37. </script>
  38. </head>
  39. <body onload="initialize()" onunload="GUnload()">
  40. <input type="text" name="address" size="50" value="烟台市西盛街28号第一大道" onblur="showAddress(this.value);" />
  41. <div id="map_canvas" style="width: 500px; height: 300px"></div>
  42. </body>
  43. </html>
在小站上的示例是基于script的charset属性:
http://www.t6new.cn/feature/maptest.html
内容概要:本文围绕VMware虚拟化环境在毕业设计中的应用,重点探讨其在网络安全与AI模型训练两大领域的实践价值。通过搭建高度隔离、可复现的虚拟化环境,解决传统物理机实验中存在的环境配置复杂、攻击场景难还原、GPU资源难以高效利用等问题。文章详细介绍了嵌套虚拟化、GPU直通(passthrough)、虚拟防火墙等核心技术,并结合具体场景提供实战操作流程与代码示例,包括SQL注入攻防实验中基于vSwitch端口镜像的流量捕获,以及PyTorch分布式训练中通过GPU直通实现接近物理机性能的模型训练效果。同时展望了智能化实验编排、边缘虚拟化和绿色计算等未来发展方向。; 适合人群:计算机相关专业本科高年级学生或研究生,具备一定虚拟化基础、网络安全或人工智能背景,正在进行或计划开展相关方向毕业设计的研究者;; 使用场景及目标:①构建可控的网络安全实验环境,实现攻击流量精准捕获与WAF防护验证;②在虚拟机中高效开展AI模型训练,充分利用GPU资源并评估性能损耗;③掌握VMware ESXi命令行与vSphere平台协同配置的关键技能; 阅读建议:建议读者结合VMware实验平台动手实践文中提供的esxcli命令与网络拓扑配置,重点关注GPU直通的硬件前提条件与端口镜像的混杂模式设置,同时可延伸探索自动化脚本编写与能效优化策略。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值