Copy codeThe Code is as follows: <HTML>
<HEAD>
<TITLE> Read-Only simulation in the drop-down box </TITLE>
<Script type = "text/javascript">
// Set the drop-down list read-only according to the drop-down list 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>
<! -- Directly set the drop-down box to read-only -->
<Select onbeforeactivate = "return false" onfocus = "this. blur ()" onmouseover = "this. setCapture ()" onmouseout = "this. releaseCapture ()">
</BODY>
</HTML>
If it is ASP. NET, it is written belowCopy codeThe Code is as follows: 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 ()");