Here api 此处映射中的JavaScript错误

Here api 此处映射中的JavaScript错误,here-api,Here Api,当主体中有样式表时,这里映射Firefox和Chrome(但不是IE)中的JavaScript API错误 工作示例: <!DOCTYPE html> <html> <head> <title>Working</title> <script type="text/javascript" src="http://js.api.here.com/se/2.5.3/jsl.js"></script>

当主体中有样式表时,这里映射Firefox和Chrome(但不是IE)中的JavaScript API错误

工作示例:

<!DOCTYPE html>
<html>
<head>
    <title>Working</title>
    <script type="text/javascript" src="http://js.api.here.com/se/2.5.3/jsl.js"></script>
    <link rel="stylesheet" type="text/css" href="http://www.w3.org/2008/site/css/minimum" />
</head>
<body>
    <div id="map" style="height: 500px; width: 500px"></div>
    <script type="text/javascript">
        nokia.Settings.set('appId', *REMOVED*);
        nokia.Settings.set('authenticationToken', *REMOVED*);
        new nokia.maps.map.Display(document.getElementById('map'));
    </script>
</body>
</html>
看起来正在发生的事情是document。样式表的主体中的元素在头部的元素之后,因此这会尝试操作外部样式表,而不是它刚刚创建的样式元素。

根据on链接:

如果使用了rel属性,则link元素仅限于头部 元素


因此,您的HTML5标记无效,因为链接不应该出现在正文中,这是元数据内容,应该放在标题中。显然IE出于某种原因变得更加宽容了(我想这里一定使用了某种特定于IE的代码,试图使其符合标准,这恰好接受了正文中的链接作为副产品)

感谢您的回复。我知道这是无效的HTML,但不幸的是每个浏览器都支持它。可能发生的情况是,我们的应用程序嵌入到其他网站中,这让我们受制于它们的HTML有效性。对于稍后阅读本文的人,我们最终将地图放入iframe中。地图代码在那里很好,而且比让第三方修复他们的网站要容易得多。
<!DOCTYPE html>
<html>
<head>
    <title>Failing</title>
    <script type="text/javascript" src="http://js.api.here.com/se/2.5.3/jsl.js"></script>
</head>
<body>
    <div id="map" style="height: 500px; width: 500px"></div>
    <link rel="stylesheet" type="text/css" href="http://www.w3.org/2008/site/css/minimum" />
    <script type="text/javascript">
        nokia.Settings.set('appId', *REMOVED*);
        nokia.Settings.set('authenticationToken', *REMOVED*);
        new nokia.maps.map.Display(document.getElementById('map'));
    </script>
</body>
</html>
var f = c.styleSheets, p = f.length, a, k, m = c.createElement("style");
m.setAttribute("type", "text/css");
c.getElementsByTagName("head")[0].appendChild(m);
a = f[f.length - 1];