技术头条 - 一个快速在微博传播文章的方式     搜索本站
您现在的位置首页 --> CSS/HTML --> CSS让你的IE浏览器崩溃

CSS让你的IE浏览器崩溃

浏览:2774次  出处信息

严格来说不单是CSS就能令IE浏览器崩溃(crash),而要配合相应的XHTML架构。到现时为止发现有两种正常写法及一种错误结构分别导致会IE6、IE7崩溃(crash),至于原因我尝试寻找过答案但至今还没找到…如你有这方面的认识或更详细的资料很希望你能分享!

1 crash IE6 code

Demo:http://blog.gulu77.com/demo/200808/crash_ie6.html

此BUG只存在IE6中,当伪类为 a:active 时同样会遇到此问题

<style type="text/css">
a{position:relative;}
a:hover{float:left;}
</style>

<a href="">崩溃IE6 ,crash ie6</a>

解决方案:为 <a> 添加 zoom:1; 令其触发haslayout

<style type="text/css">
a{position:relative;zoom:1;}
a:hover{float:left;}
</style>

2 crash IE6 code

这是HTML结构错误而导致IE6的崩溃,在<col width="100"/>前或后添加任何字符均会导致IE6 Crash

Demo:http://blog.gulu77.com/demo/200808/HTML_errors_crash_ie6.html

<table style="table-layout:fixed;">
<colgroup>
<col width="100"/>Crash IE6
</colgroup>
</table>

Bug from yoogisa http://forum.standardmag.org/viewtopic.php?pid=14282#p14282
css 경우는 아닌데 doctype을 선언한 상태에서 문법적 오류가 있는 코드를 넣으면 ie6에서 브라우저가 다운되는 현상을 격기는 했습니다.개발쪽에서 처리하다가 코드가

3 crash IE7 code

Demo:http://blog.gulu77.com/demo/200808/crash_ie7.html

Bug from 偷米饭,此bug只存在IE7中据估计是处理省略字的时候导致IE7崩溃.

<style type="text/css">
div{float:left;width:175px;}
ul{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}
li{position:relative;}
</style>

<div>
<ul>
<li>崩溃崩溃崩溃崩溃崩溃crash ie7</li>
<li>崩溃崩溃崩溃崩溃崩溃crash ie7</li>
</ul>
</div>

解决方案:为 <li> 添加 zoom:1; 令其触发haslayout

<style type="text/css">
div{float:left;width:175px;}
ul{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}
li{position:relative;zoom:1;}
</style>

4 crash IE6 code

Demo:http://blog.gulu77.com/demo/200808/crash_ie6_test1.html
当再次改变定位时浏览器崩溃,但似乎也需要N个帮凶才会导致崩溃的代码中CSS table的相属性都缺一不可。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <title>CRASH-IE,CSS让你的IE浏览器崩溃</title>
 <style type="text/css">
   html, body {overflow: hidden;scrollbar-base-color: #330066;} 
   .crash {position:absolute;left:200px;top:200px;width:200px;}
 </style>
 <script type="text/javascript">
   function galgenfrist() {
   window.setTimeout('crashIE();',1000);
   }

 function crashIE() {
   var moveNode = document.getElementById("move");
   if(moveNode) {
   moveNode.style.top = "100px";
   moveNode.style.left = "200px";
   }
   }
 </script>
 </head>

<body onload="galgenfrist();">
 <h1>CRASH-IE</h1>
 <div id="move" class="crash">
 <table>
 <tbody>
 <tr>
 <td>
 <textarea></textarea>
 </td>
 </tr>
 </tbody>
 </table>
 </div> 
 </body>
 </html>

5 crash IE6 code

Demo:http://blog.gulu77.com/demo/200808/crash_ie6_test2.html
具体引起的原因暂时无法解析,但在兼容性和执行效率来看一般不会采取这样的写法。

<script>for (x in document.write) { document.write(x);}</script>

6 crash IE6 code

Demo:http://blog.gulu77.com/demo/200808/crash_ie6_test3.html
传说是一名日本人发现的,table中直接放置内容,在IE6会引起Mshtml.all模块损坏而关闭浏览器,非IE6则安全无恙。

<style>*{position:relative}</style><table><input></table>

7 crash IE6 code

Demo:http://blog.gulu77.com/demo/200808/crash_ie6_test4.html

<body onLoad=”window()”>

8 crash IE6 code

Demo:http://blog.gulu77.com/demo/200808/crash_ie6_test5.html
CSS中出现@+任意字符+/* 立即崩溃。

<style>@;/*</style>

注:4~8 from http://www.catswhocode.com/blog/6-html-and-javascript-codes-to-crash-ie6

版本:20090218

建议继续学习:

  1. 浏览器的工作原理:新式网络浏览器幕后揭秘    (阅读:19210)
  2. 浅析http协议、cookies和session机制、浏览器缓存    (阅读:15467)
  3. 从输入 URL 到页面加载完成的过程中都发生了什么事情?    (阅读:14217)
  4. 程序员眼里IE浏览器是什么样的    (阅读:6595)
  5. 浏览器的渲染原理简介    (阅读:6131)
  6. 各种浏览器审查、监听http头工具介绍    (阅读:6010)
  7. 图说浏览器战争:火狐、微软、谷歌那些事    (阅读:5822)
  8. 浏览器缓存机制    (阅读:5613)
  9. [译]Google Chrome中的高性能网络    (阅读:4842)
  10. 12款很棒的浏览器兼容性测试工具推荐    (阅读:4691)
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
© 2009 - 2024 by blogread.cn 微博:@IT技术博客大学习

京ICP备15002552号-1