asp.net - Google 地图信息窗口 - 使用 JavaScript 更改我的位置 - Asp.NET
问题描述
我在保存会话后尝试将我的网页重定向到我的 asp.net 项目的另一个路径,代码在这里:
(function (marker, data) {
google.maps.event.addListener(marker, "click", function (e) {
infoWindow.setContent('<div class="card" style ="width:200px;height:auto;">' +
'<img class="card-img-top" src='+data.photo+' style="width:200px;height:auto;" >' +
'<div class="card-body">'+
'<h5 class="card-title">' + data.title + '</h5>' +
'<p class="card-text">' + data.description + '</p>' +
'<button id="btn_seedetails" >Click me</button>' +
'</div>' +
'</div >' );
infoWindow.open(map, marker);
google.maps.event.addDomListener(document.getElementById('btn_seedetails'), 'click', sendit);
});
function sendit() {
'<%Session["ID_EVENT"] = "' + data.id + '"; %>';
document.location.href = "AllConflicts.aspx";
location.replace("AllConflicts.aspx")
}
})(marker, data);
解决方案
也许使用查询字符串来传递数据:
function sendit() {
window.location.href("AllConflicts.aspx?id=" + data.id);
}
在 JS 中重定向也是一个不错的参考如何重定向到另一个网页?
也许 data.id 在函数中不可用。您可能希望对sendit
函数使用输入参数。
推荐阅读
- javascript - 提交表单后重定向
- javascript - 在 2 个字段中拆分 Javascript 中的字符串
- python - 在 Python 中解析 DN、来自 LDAP URL 的属性
- html - 3 列流体 flexbox 和 rtl
- geojson - 是否可以在本地可视化超过 100kB 的 GeoJSON 文件?
- jenkins - 詹金斯 - GitHub 集成
- java - 如何将 DB 中的结果集转换为 Java 中的合并语句?
- javascript - Woocommerce:购物车/结帐页面上的 Javascript 问题,在灯箱中打开图像
- hyperledger-fabric - 什么是超级账本结构中 configtx.yaml 中的配置文件部分
- javascript - JavaScript 循环遍历 n 维数组