日期:2014-05-16  浏览次数:20371 次

请问这条语句去掉为什么就不行了?
<style>
#Text1     {
z-index:19;width:200px;  
}
#s1   {
position:relative;top:0px;
width:19px;   text-align:right;   overflow:hidden;   z-index:8;
}
#Select1     {
position:relative;  
}
</style>
<span>
<input   id= "Text1 "   type= "text "   value= " "   onpropertychange= "document.all.Select1.options[flag].innerText=this.value "> <span   id= "s1 "   >
<select   id= "Select1 "   style= "left:expression(18-this.clientWidth); "
//这里的style为什么不能去掉?在后面的loadit函数里不是也定义好了吗?
  onpropertychange= "setValue(this.selectedIndex);this.parentNode.previousSibling.value   =   this.options[this.selectedIndex].innerText; "   style= "width:219px ">
<option> Combox   test1 </option>
<option> 1 </option>
<option> 2 </option>
<option> 3 </option>
<option> 4 </option>
</select>
</span>
</span>

<script>
var   flag;
window.load=loadit();    
function     loadit()    
{  
getElementById( "s1 ").style.left=this.firstChild.clientWidth   -   19   ;
getElementById( "Select1 ").style.left=18-this.clientWidth;
}    

function   setValue(f)
{
flag   =   f;
}
</script>

------解决方案--------------------
<style>
#Text1 {
z-index:19;width:200px;
}
#s2 {
z-index:19;width:200px;
}
#s1 {
position:relative;top:0px;
width:19px; text-align:right; overflow:hidden; z-index:8;
}
#Select1 {
position:relative;
}
</style>
<span id= "dfd ">
<input id= "Text1 " type= "text " value= " " /> <span id= "s1 " onpropertychange= "document.all.Select1.options[flag].innerText=this.value; "> <select id= "Select1 " onpropertychange= "setValue(this.selectedIndex);this.parentNode.previousSibling.value = this.options[this.selectedIndex].innerText; " style= "width:219px ">
<!-- <span id= "s1 " onpropertychange= "this.value=document.all.Select1.options[flag].innerText; " 这样会有stack overflow at 0-->
<option> Combox test1 </option>
<option> 1 </option>
<option> 2 </option>
<option> 3 </option>
<option> 4 </option>
</select>
</span>
</span>

<script>
var flag;
window.load=loadit();
function loadit()
{
//alert(document.getElementById( "Text1 ").tagName);
//alert(document.getElementById( "s1 ").firstChild.clientWidth);
//document.getElementById( "s1 ").style.left=document.getElementById( "s1 ").firstChild.clientWidth - 19 ;
document.getElementById( "Select1 ").style.left=18-document.getElementById( "Select1 ").clientWidth;
}

function setValue(f)
{
flag = f;
}
</script>
我去掉了也没事,是代码其他地方的问题吧