javascript - 从函数设置 src 时,iframe HTML 标记拒绝连接
问题描述
我正在尝试使用函数查找纬度和经度。然后使用这些值在 iframe 中设置 src 以在 Google 地图中显示位置。但谷歌拒绝连接。当从 iframe 设置相同的“src”时,它可以工作。两者是相同的,只是函数动态生成 src。为什么它不起作用以及如何使它起作用?
</script>
.....
function showPosition(position){
lat = position.coords.latitude;
long = position.coords.longitude;
lin = "https://maps.google.com/maps?q="+lat+","+long+"&hl=es;z=14&output=embed";
fh.innerHTML = lin;
document.getElementById('pmap').src = lin;
}
</script>
<iframe
id = "pmap" width="600" height="450"
src = "https://maps.google.com/maps?q=25.6552912,88.6423475&hl=es;z=14&output=embed">
</iframe>
解决方案
推荐阅读
- python - 如何使用其内存地址访问 Pytorch 张量数据?
- autodesk-forge - 像素比较过度缩放
- c# - 在 ASP.NET MVC 中从部分视图发布动态表单数据
- ruby-on-rails - 如何使用 Ruby on Rails 解决“N+1”问题
- python - 无法从 HuggingFace 包加载数据集
- javascript - Dom 中的目标元素与 Array 中存在的类匹配
- reactjs - React SSR:组件呈现但 URL 不变
- postgresql - 决定是否将数据存储在 jsonb 数组或 Postgres 中的新表中
- google-cloud-platform - 如何使用 Google Drive API 访问“我的单元”文件
- c# - 了解异步方法中的“等待”用法