1.这是定义信息框代码
function CreateOpts(content) {
var opts = {
width : 350,
height : 238,
title : "<strong>设备信息:</strong><br><br>"
}
content = '<div id="LoginBox">'
+ '<div class="row" style="width: 300px;height: 35px;margin-top:-10px;">名字: </div>'
+ '<div class="row" style="width: 300px;height: 35px;">覆盖范围: </div>'
+ '<div class="row" style="width: 300px;height: 35px;">安装地址: </div>'
+ '<div class="row" style="width: 300px;height: 35px;">一线维护人:</div>'
+ '<div class="row">'
+ '<input οnclick="quxiao(this)" type="button" id="btn1" value="取消" style="width: 100px;height:30px;margin-top: 20px;margin-left: 120px;">'
+ '</div></div>';
var infoWindow = new BMap.InfoWindow(content, opts); // 创建信息窗口对象 第一个参数为内容
marker.addEventListener("click", function() {
map.openInfoWindow(infoWindow, map.getCenter()); // 打开信息窗口
});
}
function quxiao(name) {
name1=$(name).parent().parent().children(':first').next().next().html();
var arr=name1.split(':');
window.location.href="${pageContext.request.contextPath }/device/quxiao.do?name="+encodeURIComponent(encodeURIComponent(arr[1],'UTF-8'),'UTF-8');
}
这种方式可以正常运行。事件必须要立刻绑定,如红色部分。如果按照id或者class来查会找不到。