javascript - IE11 中的 Google map 给出 "Unspecified error"

标签 javascript google-maps internet-explorer google-maps-api-3 internet-explorer-11

在我们的一个客户的网站上使用自定义 Google map 时,我遇到了一个非常奇怪的错误。 map 上有一些标记,当您打开标记时,您可以看到一个包含该位置地址的对话框。当我在 IE11 中关闭此对话框(显然是通过单击十字)时,我收到“未指定错误”。由于某种原因,该错误是从方法“getBoundingClientRect()”引发的。其他浏览器都没有这个问题(甚至 IE8 也没有)。

我使用的是 Google Maps API 版本 3.14。

有人知道这可能是什么吗?我不确定是否有必要放置任何代码,但如果这能让一切变得更加清晰,我愿意这样做。

最佳答案

您可以对 IE 使用此修复程序(将此代码放在顶部):

HTMLElement.prototype._getBoundingClientRect=HTMLElement.prototype.getBoundingClientRect; 
HTMLElement.prototype.getBoundingClientRect = function() {
    try {
        return this._getBoundingClientRect();
    } catch(e) {
        return { top : this.offsetTop, left : this.offsetLeft };
    }
}

关于javascript - IE11 中的 Google map 给出 "Unspecified error",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21261498/

相关文章:

javascript - HTML 如何根据 javascript 函数的返回值限制文本输入?

javascript - 谷歌地图信息窗口按钮未传递值?

javascript - 无法通过传递经纬度数组来设置折线的路径

html - Internet Explorer 非确定性布局

java - Excel VBA 从下载对话框打开文件

javascript - 将标题与内容对齐

javascript - 借助 Knockout.js 订阅对一组对象进行动画处理?

javascript - jQuery的$如何既是函数又是对象?

android - 将 KML 层添加到 Android map 应用程序

html - IE6/7右浮动bug