Javascript 使Internet Explorer 8崩溃的简单网页

Javascript 使Internet Explorer 8崩溃的简单网页,javascript,google-maps,html,internet-explorer-8,crash,Javascript,Google Maps,Html,Internet Explorer 8,Crash,我在几个使用Internet Explorer 8的不同Windows 7计算机上尝试了以下HTML代码,但在任何地方都会导致Internet Explorer崩溃。我无法用IE7或用IE8在Windows XP上重现这一点 <!doctype html> <head> <title>Crashes IE8 on Win7</title> <style> article { display: block; } </style&g

我在几个使用Internet Explorer 8的不同Windows 7计算机上尝试了以下HTML代码,但在任何地方都会导致Internet Explorer崩溃。我无法用IE7或用IE8在Windows XP上重现这一点

<!doctype html>

<head>
<title>Crashes IE8 on Win7</title>
<style>
article { display: block; }
</style>
<script>
document.createElement('article');
document.createElement('nav');

function initialize() {
    var map = new google.maps.Map(document.getElementById("map_canvas"), {});
}

function loadScript() {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=initialize";
    document.body.appendChild(script);
}

window.onload = loadScript;
</script>
</head>
<body>

<nav><ul><li>
    <div id="map_canvas"></div>
    <article>
</li></ul></nav>

</body>

在Win7上崩溃IE8
项目{显示:块;}
document.createElement(“条款”);
document.createElement('nav');
函数初始化(){
var map=new google.maps.map(document.getElementById(“map_canvas”),{});
}
函数loadScript(){
var script=document.createElement(“脚本”);
script.type=“text/javascript”;
script.src=”http://maps.google.com/maps/api/js?sensor=false&callback=initialize";
document.body.appendChild(脚本);
}
window.onload=loadScript;
页面中唯一真正的bug是缺少的
标记。其余的都是使IE崩溃所必需的。我相信我可以通过分解GoogleMapsAPI来进一步缩小范围,但这对我来说有点太过分了

其他人能复制这个吗,或者他们的一些奇怪的配置只适用于我测试过的所有机器


编辑:更清楚地说,我不是在寻找代码的修复程序。(修复方法是:添加缺少的
标记。)我正在查看这是否会使Win7上的IE8崩溃其他人也会崩溃,也许我应该在某个地方报告这一情况,因为我知道崩溃通常可以用来控制受害者的计算机。

我可以在Windows 7上使用IE8复制您的问题。这很可能与这一点有关,这表明问题是在页面加载完成之前试图修改元素引起的。如果是这种情况,您可以通过在页面完成加载后使用jQuery调用loadScript方法来解决问题。例如

<script>
    $().ready(function() {
        loadScript();
    });
</script>

$().ready(函数()){
loadScript();
});

尝试将脚本向下移动到页面底部

我还将整理以下内容:

  • 删除正文中的非html代码
  • 添加开始和结束html标记
这对我很有用:

<!doctype html>
<html>
<head>
<title>Crashes IE8 on Win7</title>
<style type="text/css">
article { display: block; }
</style>

</head>
<body>

<div id="map_canvas"></div>

<script type="text/javascript">
document.createElement('article');
document.createElement('nav');

function initialize() {
    var map = new google.maps.Map(document.getElementById("map_canvas"), {});
}

function loadScript() {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=initialize";
    document.body.appendChild(script);
}
window.onload = loadScript;
</script>
</body>
</html>

在Win7上崩溃IE8
项目{显示:块;}
document.createElement(“条款”);
document.createElement('nav');
函数初始化(){
var map=new google.maps.map(document.getElementById(“map_canvas”),{});
}
函数loadScript(){
var script=document.createElement(“脚本”);
script.type=“text/javascript”;
script.src=”http://maps.google.com/maps/api/js?sensor=false&callback=initialize";
document.body.appendChild(脚本);
}
window.onload=loadScript;

有趣的是,在Windows XP上,IE 8似乎没有崩溃。你试过添加
标签吗?我在我的Win7和IE8上试过,它确实崩溃了。如果我添加文章的结尾标记,它不会崩溃。我记得以前Netscape遇到@import标签时会严重崩溃。有人知道如何向微软报告吗?:)抱歉,我还应该说您需要在窗口外发表评论。onload=loadScript行。我建议的修复在我尝试itHow怪异时起了作用,我尝试了它(我确实删除了window.onload行),但它仍然崩溃。但是,请记住,我并不是在寻找我的代码修复程序……嗨,太空猴子。谢谢你的回复。然而,我想你误解了我发帖的原因。我不是在寻找我的HTML代码的修复程序。我甚至在原来的帖子中自己写了修复程序。我想你可以说我唯一的问题是,这是否也会对其他人造成影响。我应该更清楚这一点;我想知道我是否应该在某个地方报告这一点,因为崩溃通常是网络攻击的切入点。啊,哎呀。好吧,我可以确认原始代码确实使我的IE8崩溃了。但是,我不认为这是可以报告的,因为代码本身是故意破坏的。