欢迎光临

木子屋

标题: IE6.0下广告代码离奇消失之谜

作者: dnawo

日期: 2009-07-20 04:23 PM

分类: 脚本语言

内容: 复制内容到剪贴板 程序代码<!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=gb2312" />
<title>AD</title>
</head>
<body>
<script type="text/javascript">
var div = document.createElement("div");
div.style.position = "absolute";
div.innerHTML = "<img src='http://img1.gtimg.com/news/pics/19354/19354360.jpg' border='0' />";
try{document.getElementsByTagName("body").item(0).appendChild(div)}catch(ex){};
div.style.top = "300px";
div.style.left = "300px";
</script>
</body>
</html>
上边代码在IE6.0运行效果：首页打开页面，广告显示一会后自动消失，刷新一下则无此问题。经过多次测试，发现：
1).注释掉最后两句不会有自动消失的问题
复制内容到剪贴板 程序代码<!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=gb2312" />
<title>AD</title>
</head>
<body>
<script type="text/javascript">
var div = document.createElement("div");
div.style.position = "absolute";
div.innerHTML = "<img src='http://img1.gtimg.com/news/pics/19354/19354360.jpg' border='0' />";
try{document.getElementsByTagName("body").item(0).appendChild(div)}catch(ex){};
//div.style.top = "300px";
//div.style.left = "300px";
</script>
</body>
</html>
2).给div设置背景色后也不会有自动消失的问题
复制内容到剪贴板 程序代码<!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=gb2312" />
<title>AD</title>
</head>
<body>
<script type="text/javascript">
var div = document.createElement("div");
div.style.position = "absolute";
div.innerHTML = "<img src='http://img1.gtimg.com/news/pics/19354/19354360.jpg' border='0' />";
div.style.backgroundColor = "#000000";
try{document.getElementsByTagName("body").item(0).appendChild(div)}catch(ex){};
div.style.top = "300px";
div.style.left = "300px";
</script>
</body>
</html>
具体原因未知：（

+ 查看当前日志评论 (0)

登录

────────────

木子屋

PJBlog3 v3.2.9.518 Inside.

Processed In 0.926 ms

返回

标题: IE6.0下广告代码离奇消失之谜

你没有权限发表评论

────────────

木子屋

PJBlog3 v3.2.9.518 Inside.

Processed In 0.926 ms

返回

暂无评论

返回

────────────

木子屋

PJBlog3 v3.2.9.518 Inside.

Processed In 0.961 ms

返回