Ie8 支持 function.bind () 方法
<script type = "text/javascript"> if (! function.prototype.bind) {function.prototype.bind = function (othis) {if (typeof this! == "function") {tiro o novo typeError ("function.protype.bind - o que está tentando ser ligado não é chamado"); } var aargs = array.prototype.slice.call (argumentos, 1), ftobind = this, fnop = function () {}, fbound = function () {return ftobind.apply (itens fnop && othis? }; fnop.prototype = this.prototype; fbound.prototype = new FNOP (); retornar fbound; }; } </script>主要解决 “百度地图” 官网上的例子的 Bug , 摘取如下代码:
<! Doctype html> <html> <head> <meta http-equiv = "content-type" content = "text /html; charset = utf-8" /> <meta name = "viewport" content = "inicial-escala = 1.0, user-scalable = 100 ° /<estilo" "; 100%; margem: 0; font-família: "微软雅黑";} #allmap {width: 100%; altura: 500px;} p {margin-left: 5px; font-size: 14px;} </style> <script type = "text/javascript" src = "http://api.map.baidu.com/api?v=2.0&ak=39b92e64ae5622663cececcd8ab8ab8eb8eb92e64e56226633 src = "http://libs.baidu.com/jquery/1.9.0/jquery.js"> </script> <tittle> 给多个点添加信息窗口 </title> <script type = "text/javascript"> if (! function.protype.bind) {fUNCTTOType.bind = sTINTHIS (! TypeError ("function.prototype.bind - o que está tentando ser amarrado não é chamável"); } var aargs = array.prototype.slice.call (argumentos, 1), ftobind = this, fnop = function () {}, fbound = function () {return ftobind.apply (itens fnop && othis? }; fnop.prototype = this.prototype; fbound.prototype = new FNOP (); retornar fbound; }; } </script> </adhead> <body> <div id = "allmap"> </div> <p> 点击标注点 , 可查看由纯文本构成的简单型信息窗口 </p> </body> </html> <script type = "text/javascript"> // 百度地图 api 功能 map = new Bmap.map ("Allmap"); map.CenteRandzoom (New Bmap.Point (116.417854.39.921988), 15); var data_info = [[116.417854.39.921988, "地址 : : 88 号乐天银泰百货八层"], [116.406605,39.921585, "地址 : 北京市东城区东华门大街"], [116.412222,91912345 "; var opts = {width: 250, // 信息窗口宽度 altura: 80, // título: "信息窗口", // 信息窗口标题 EnableMessage: true // 设置允许信息窗发送短息}; for (var i = 0; i <data_info.length; i ++) {var marker = new Bmap.marker (new Bmap.Point (data_info [i] [0], data_info [i] [1])); // 创建标注 var content = data_info [i] [2]; map.addoverlay (marcador); // 将标注添加到地图中 marker.addeventListener ("clique", openinfo.bind (null, content)); } função openInfo (content, e) {var p = e.target; var point = new bmap.point (P.GetPosition (). LNG, P.GetPosition (). Lat); var infowindow = new bmap.infowindow (conteúdo, opts); // 创建信息窗口对象 map.openinfowindow (infowindow, ponto); // 开启信息窗口} </script>