IE8 支持 function.bind () 方法
<script type = "text/javaScript"> if (! function.prototype.bind) {function.prototype.bind = function (othis) {if (typeof thyf este! == "function") {throle new typeError ("function.prototype.bind - lo que está intentando estar atado no es llamable");; } var aargs = array.prototype.slice.call (argumentos, 1), fTobind = this, fnop = function () {}, fbound = function () {return ftobind.apply (esta instancia de fnop && othis? this: oThis, aargs.concat (array.pototype.slice.call (argumentos));););); }; fnop.prototype = this.prototype; fbound.prototype = new Fnop (); regresar fbound; }; } </script>主要解决 “百度地图 百度地图” 官网上的例子的 Error , : :
<! DOCTYPE HTML> <HTML> <HEAD> <meta http-equiv = "content-type" content = "text /html; charset = utf-8" /> <meta name = "viewport" content = "inicial-escale = 1.0, user-scalable = no" /> <style tipo = "text /css" 100%; margen: 0; Font-Family: "微软雅黑";} #AllMap {ancho: 100%; altura: 500px;} p {margen-izquierda: 5px; font-size: 14px;} </style> <script type = "text/javaScript" src = "http://api.map.baidu.com/api?v=2.0&ak=39b92e64ae56222663ceceaccd8ab8eb1"> </script> src = "http://libs.baidu.com/jquery/1.9.0/jquery.js"> </script> <title> 给多个点添加信息窗口 </title> <script type = "text/javascript"> if (! function.prototype.bind) {function.prototype.bind = function (othis) TypeError ("function.prototype.bind: lo que está tratando de estar atado no es llamable"); } var aargs = array.prototype.slice.call (argumentos, 1), fTobind = this, fnop = function () {}, fbound = function () {return ftobind.apply (esta instancia de fnop && othis? this: oThis, aargs.concat (array.pototype.slice.call (argumentos));););); }; fnop.prototype = this.prototype; fbound.prototype = new Fnop (); regresar fbound; }; } </script> </head> <body> <div id = "allMap"> </div> <p> 点击标注点 , 可查看由纯文本构成的简单型信息窗口 </p> </body> </html> <script type = "text/javascript"> // 百度地图 api 功能 map = new bmap.map ("allmap"); MAP.CenterandZoom (nuevo BMAP.Point (116.417854,39.921988), 15); var data_info = [[116.417854,39.921988, "地址 : 北京市东城区王府井大街 88 号乐天银泰百货八层"], [116.406605,39.921585, "地址 : 北京市东城区东华门大街"], [116.4122222,39.912345, "地址 北京市东城区正义路甲 : : : : :"]; Var opts = {ancho: 250, // 信息窗口宽度 Altura: 80, // 信息窗口高度 Título: "信息窗口", // 信息窗口标题 EnableMessage: True // 设置允许信息窗发送短息}; for (var i = 0; i <data_info.length; i ++) {var marcador = 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 ("hacer clic", openInfo.bind (null, content)); } función OpenInfo (content, e) {var p = e.target; Var Point = new BMap.Point (p.getPosition (). lng, p.getPosition (). Lat); var infowindow = new BMap.infowindow (contenido, opción); // 创建信息窗口对象 map.openinfowindow (infowindow, punto); // 开启信息窗口} </script>