c#中的控件DropDownList要實現默打開確實不容易,之前也是想過頁面上的點擊之后就打開了,那直接模擬點擊不就行了,試過后大失所望,根本沒有效果。
於是網上找到了一個例子能實現IE瀏覽器下的打開,具體實現看下面例子
<asp:DropDownList ID="ddlgsmc" runat="server" Height="20px" ></asp:DropDownList>
js中的代碼
window.onload=function (){
document.getElementById("ddlgsmc").focus();
var WshShell = new ActiveXObject("Wscript.Shell");
try {
WshShell.SendKeys("%{DOWN}");
} catch (e) { }
WshShell.Quit;
}
