在放大镜下,你可以看到每一片雪花都是一幅幅精美的图案:有的是晶莹的薄片,有的像白亮的银针,有的像一把张开的小扇,有的像夜空的星星……
<HTML>
<HEAD>
<TITLE>下拉框模拟只读</TITLE>
<script type="text/javascript">
//根据下拉框ID设置下拉框只读
function setReadOnly(obj_id){
var obj = document.getElementById(obj_id);
obj.onmouseover = function(){
obj.setCapture();
}
obj.onmouseout = function(){
obj.releaseCapture();
}
obj.onfocus = function(){
obj.blur();
}
obj.onbeforeactivate = function(){
return false;
}
}
</script>
</HEAD>
<BODY>
<span id="span_select">
<select id="id_select">
<option value="1">AAAAAAAAA</option>
<option value="2">BBBBBBBBB</option>
<option value="3">CCCCCCCCC</option>
<option value="4">DDDDDDDDD</option>
</select>
</span>
<script type="text/javascript">
setReadOnly("span_select");
</script>
<!-- 直接设置下拉框只读 -->
<select onbeforeactivate="return false" onfocus="this.blur()" onmouseover="this.setCapture()" onmouseout="this.releaseCapture()">
</BODY>
</HTML>
如果是ASP.NET ,则是下面的写法
this.ddlSysCategory.Attributes.Add("onfocus","this.blur();");
this.ddlSysCategory.Attributes.Add("onbeforeactivate","return false");
this.ddlSysCategory.Attributes.Add("onmouseover","this.setCapture()");
this.ddlSysCategory.Attributes.Add("onmouseout","this.releaseCapture()");
以上就是asp.net 实现下拉框只读功能。生活是一棵大树,我就是一片小树叶,我摇啊摇,我真快乐。更多关于asp.net 实现下拉框只读功能请关注haodaima.com其它相关文章!