相思资源网 Design By www.200059.com
复制代码 代码如下:
<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()");
<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()");
标签:
下拉框,只读
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无asp.net 实现下拉框只读功能的评论...