<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style type="text/css">
div {
width: 300px;
height: 200px;
background-color: Yellow;
}
</style>
<script type="text/javascript">
onload = function () {
//操作float样式的时候,IE与其他浏览器不太一样。
//IE:obj.style.styleFloat=‘right’;
//其他浏览器:obj.style.cssFloat=‘right’;
document.getElementById('btn').onclick = function () {
var dvObj = document.getElementById('dv');
if (typeof (dvObj.style.styleFloat) == 'string') {
//是IE
dvObj.style.styleFloat = 'right';
} else {
//不是IE
dvObj.style.cssFloat = 'right';
};
};
};
</script>
</head>
<body>
<input type="button" name="name" value="浮动" id="btn" />
<div id="dv">
</div>
</body>
</html>