IE8 支持 function.bind () 方法
<script type = "text/javascript"> if (! function.prototype.bind) {function.prototype.bind = function (othis) {if (typeof this! == "function") {throw new TypeError ("function.prototype.bind - то, что пытается связать, не может вызовать"); } var aargs = array.prototype.slice.call (аргументы, 1), ftobind = this, fnop = function () {}, fbound = function () {return ftobind.apply (этот экземпляр fnop && othis? }; fnop.prototype = this.prototype; fbound.prototype = new fnop (); вернуть fbound; }; } </script>主要解决 «百度地图» 官网上的例子的 ошибка , :
<! Doctype html> <html> <head> <meta http-equiv = "content-type" content = "text /html; charset = utf-8" /> <meta name = "viewport" content = "Начальный шкал = 1,0, пользовательский scalbable = no" /> styte type = "text /css"> html {hightmble = no " /> <стиль =" csss "> 1,0, hightmable = no" /> <стиль = "csss"> 100%; маржа: 0; font-family: "微软雅黑";} #allmap {ширина: 100%; высота: 500px;} p {margin-left: 5px; размер Font: 14px;} </style> <script type = "text/javascript" src = "http://api.map.baidu.com/api?v=2.0&ak=39b92e64ae5622663ceacccd8ab8eb1"> </script> <script src = "http://libs.baidu.com/jquery/1.9.0/jquery.js"> </script> <title> 给多个点添加信息窗口 </title> <script type = "text/javascript"> if (! function.prototy.bind) {function.prototype.bind = if (! Typeerror ("function.prototype.bind - то, что пытается связать, не вызывает"); } var aargs = array.prototype.slice.call (аргументы, 1), ftobind = this, fnop = function () {}, fbound = function () {return ftobind.apply (этот экземпляр fnop && othis? }; fnop.prototype = this.prototype; fbound.prototype = new fnop (); вернуть fbound; }; } </script> </head> <body> <div id = "allmap"> </div> <p> 点击标注点 , 可查看由纯文本构成的简单型信息窗口 </p> </body> </html> <script type = "text/javascript"> // 百度地图 api 功能 map = new bmap.map ("allmap"); map.cenerandzoom (новый Bmap.point (116,417854,39,921988), 15); var data_info = [[116.417854,39.921988, "地址 : 北京市东城区王府井大街 88 号乐天银泰百货八层"], [116,406605,39,921585, "地址 : 北京市东城区东华门大街"], [116,412222,39,912345, ": : : : : : 号 号 号"]; var opts = {width: 250, // 信息窗口宽度 Высота: 80, // 信息窗口高度 Название: "信息窗口", // 信息窗口标题 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 (маркер); // 将标注添加到地图中 marker.addeventListener ("click", openInfo.bind (null, content)); } function openInfo (content, e) {var p = e.target; var point = new bmap.point (p.getposition (). lng, p.getposition (). lat); var InfoWindow = new Bmap.Infowindow (Content, Opts); // 创建信息窗口对象 map.openinfowindow (Infowindow, Point); // 开启信息窗口} </script>