Google Maps API V3 and Internet Explorer

Google Maps API V3 and Internet Explorer

本文关键字:Internet Explorer and V3 Maps API Google      更新时间:2023-09-26

我正在创建一个使用Google API的页面内使用wordpress的网站。

该地图适用于所有浏览器(Firefox,Chrome,Safari,Opera),但IE除外。

带有地图的页面是这样的

http://www.guicciardinistrozzi.it/tenute

如果我复制我链接的页面的源代码并将其复制到 html 文件中,IE 可以显示地图,就会发生奇怪的事情。

我们证明了 http://www.guicciardinistrozzi.it/tenute_/index.html

我试图用wordpress strandard的结构改变永久链接结构,但没有结果。

我使用的javascript脚本如下:

  • 伊尼齐亚利扎.js

  • 罗吉.js

地图的CSS代码是luoghi.css

你能尝试在你的标题中添加这个吗?

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

您的脚本插入不会在 IE 中发生。特别是,此行不起作用:

window.onload = loadScript;

如果手动执行loadScript事件,将显示地图。特定于 IE 的内容可能是重写了 onload 事件。

查看没有jQuery的$(document).ready等效项,以获得将侦听器添加到onload事件的更好方法。

谢谢!问题是 window.onload 事件。我已经解决了这个问题,将此代码添加到我的 inizializza.js 文件中。

函数加载脚本() {

 var script = document.createElement("script");
 script.type = "text/javascript";
 script.src ="http://maps.googleapis.com/maps/api/js?key=****&sensor=false&callback=initialize";
 document.body.appendChild(script);
 }
 window.onload = loadScript;

IE(我添加的代码)

 document.write("<script id=__ie_onload defer src=javascript:void(0)><'/script>");
 var script = document.getElementById("__ie_onload");
 script.onreadystatechange = function() {
     if (this.readyState == "complete") {
         loadScript(); // call the onload handler
     }
 };