更改背景图片的js代码错,谢谢!!
<script type= "text/javascript ">
var frmst=top.document.getElementById( "main ");
var midpic=document.getElementById( "arrow ");
alert(midpic);
function collapse()
{
if (frmst.cols== "16%,2%,* "){
frmst.cols= "0,2%,99% ";
alert(midpic);
//midpic.src= "arrowright1.gif ";
}else{
frmst.cols= "16%,2%,* ";
//midpic.src= "arrowright2.gif ";
}
}
</script>
<img id= "arrow " name= "arrow " src= "arrowright1.gif " onClick= "collapse(); ">
以上代码是在mid.htm中,这个代码主要是为了显示和隐藏左侧的frm,在隐藏和显示时中间栏的背景图片上的指示箭头是会变化的,但现在箭头变化出现我问题.愿闻其详,谢谢
------解决方案-------------------- <script type= "text/javascript ">
function collapse()
{
var frmst=top.document.getElementById( "main ");
var midpic=document.getElementById( "arrow ");
if (frmst.cols== "16%,2%,* "){
frmst.cols= "0,2%,99% ";
alert(midpic);
//midpic.src= "arrowright1.gif ";
}else{
frmst.cols= "16%,2%,* ";
//midpic.src= "arrowright2.gif ";
}
}
</script>
<img id= "arrow " name= "arrow " src= "arrowright1.gif " onClick= "collapse(); ">
你的下面的代码没错。主要是src路径要正确
------解决方案--------------------var midpic=document.getElementById( "arrow ");
要放在img生成之后,放在前面肯定是不行的