js问题(IE不行,FF可以)

来源:百度知道 编辑:UC知道 时间:2024/05/31 04:16:21
<html>
<head>
<title>Untitled Document</title>
<style>
#con
{
border:solid 1px #000;
position:relative;
width:200px;
height:24px;
}

#con dd
{
margin:0px;
padding:0px;
position:absolute;
top:0px;
left:0px;
width:200px;
height:24px;
font:12px/24px "Arial";
color:#000;
text-align:center;
z-index:1;
}

#per
{
background:#00f;
position:absolute;
top:0px;
left:0px;
width:0px;
height:24px;
z-index:0;
}

</style>
</head>
<body>
<script>
function perf()
{
var x=parseInt(document.getElementById("per").style.width);
if (x<200)
{
x+=2;
}

IE 可能是不支持 自定义标签吧,我把dd改成font就都可以了

<html>
<head>
<title>Untitled Document</title>
<style>
#con
{
border:solid 1px #000;
position:relative;
width:200px;
height:24px;
}

#con dd
{
margin:0px;
padding:0px;
position:absolute;
top:0px;
left:0px;
width:200px;
height:24px;
font:12px/24px "Arial";
color:#000;
text-align:center;
z-index:1;
}

#per
{
background:#00f;
position:absolute;
top:0px;
left:0px;
width:0px;
height:24px;
z-index:0;
}

</style>
</head>
<body>
<script>
function perf()
{
// alert(document.getElementById("con").innerHTML);// 加上这样一句, 看到输出信息你就明白问题出在哪里了
var x = parseInt(document.getElementById("per").style.width);
if (x<200)
{
x += 2;
}