---
title: "仅IE6/7/8下cssText返回值少了分号"
author: "zhouyrt"
date: "2011-03-11T10:10:26Z"
tags: []
categories: ["Web前端"]
slug: "ie6-7-8-csstext"
draft: false
lastmod: "2011-03-11T10:11:08Z"
id: 953462
url: "https://snandy.iteye.com/blog/953462"
---

如下

 

```
<!DOCTYPE html>
<html>
<head>
	<title>IE6/7/8下cssText返回值少了分号</title>
</head>
<body>
	<div style="color:red;">TEST</div>
	<script>
		var div = document.getElementsByTagName('div');
		alert(div[0].style.cssText);
	</script>
</body>
</html>
```

 

 

 各浏览器输出如下

 

IE6/7/8 :

 

![](http://dl.iteye.com/upload/attachment/433803/e9bd17e6-4350-3d2b-9c4f-52a6cb07546b.jpg)

 

IE9/Firefox/Chrome/Safari/Opera :

 

![](http://dl.iteye.com/upload/attachment/433807/10d0574b-193c-3ba4-b12b-501ebb089870.jpg)

 

 

可以看到IE6/7/8中少了分号。使用cssText属性时需注意。