ie8支持函數.bind()方法
<script type="text/javascript"> if (!Function.prototype.bind) { Function.prototype.bind = function (oThis) { if (typeof this !== "function") { throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); } var aargs = array.prototype.slice.call(grabindes,1),ftobind = this,fnop = function(){},fbound = function(){return ftobind.apply(this ackitof fnop &&&&&&& othis? }; fnop.protype = this.prototype; fbound.protype = new FNOP();返回fbound; }; } </script>主要解決“百度地圖”官網上的例子的bug,摘取如下代碼::
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> body, html {width: 100%;height: 100%; margin:0; font-family:“微軟雅黑”;} #allmap {width:100%;高度:500px;} p {margin-left:5px; font-size:14px;} </style> <script type =“ text/javaScript” src =“ http://api.map.baidu.com/api?v=2.0 2.0&ak = 39b92e62e64ae56266626666663ceceaccd8ab8eb1 src =“ http://libs.baidu.com/jquery/1.9.0/jquery.js”> </script> </script> <title> </title> </title> <script> <script type =“ text/javascript”> if(!function.prototype.bind) typeError(“ function.prototype.bind-試圖被綁定的是不可呼應的”); } var aargs = array.prototype.slice.call(grabindes,1),ftobind = this,fnop = function(){},fbound = function(){return ftobind.apply(this ackitof fnop &&&&&&& othis? }; fnop.protype = this.prototype; fbound.protype = new FNOP();返回fbound; }; } </script> </head> <body> <div id =“ allmap”> </div> <p>點擊標註點map.centerandzoom(新BMAP.Point(116.417854,39.921988),15); var data_info = [[[[116.417854,39.921988,“:地址:北京市東城區王府井大街88號樂天銀泰百貨八層” 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] [0],data_info [i] [i] [1])); //創建標註var content = data_info [i] [2]; map.addoverlay(標記); //將標註添加到地圖中Marker.AddeventListener(“ click”,openinfo.bind(null,content)); }函數openInfo(content,e){var p = e.target; var point = new bmap.point(p.getPosition()。 lng,p.getPosition()。 lat); var ifrowindow = new bmap.infowindow(content,opts); //創建信息窗口對象map.openinfowwindow(Infowindow,Point); //開啟信息窗口} </script>