给服务器控件添加快捷键
做的这个功能是现在项目的四个可伸缩的栏目对应的快捷键,“49”,“50”,“51”,“52”分别对应键盘键ctrl+1,ctrl+2,ctrl+3,ctrl+4,可以通过ASCII对照表查到
1<script language="javascript">
2 function document.onkeydown()
3 {
4 if (event.keyCode == 49&&event.ctrlKey)
5 {
6 var btn = document.getElementById("ctl00_cphCommonBodyColumn_pnlConsignBasicExpand");
7
8 if (btn != event.srcElement)
9 {
10 btn.click();
11 return false;
12 }
13 }
14 if (event.keyCode == 50&&event.ctrlKey)
15 {
16 var btn = document.getElementById("ctl00_cphCommonBodyColumn_pnlCargonExpand");
17
18 if (btn != event.srcElement)
19 {
20 btn.click();
21 return false;
22 }
23 }
24 if (event.keyCode == 51&&event.ctrlKey)
25 {
26 var btn = document.getElementById("ctl00_cphCommonBodyColumn_pnlServiceExpand");
27
28 if (btn != event.srcElement)
29 {
30 btn.click();
31 return false;
32 }
33 }
34 if (event.keyCode == 52&&event.ctrlKey)
35 {
36 var btn = document.getElementById("ctl00_cphCommonBodyColumn_pnlContactExpand");
37
38 if (btn != event.srcElement)
39 {
40 btn.click();
41 return false;
42 }
43 }
44 }
45
46</script>
47
48
2 function document.onkeydown()
3 {
4 if (event.keyCode == 49&&event.ctrlKey)
5 {
6 var btn = document.getElementById("ctl00_cphCommonBodyColumn_pnlConsignBasicExpand");
7
8 if (btn != event.srcElement)
9 {
10 btn.click();
11 return false;
12 }
13 }
14 if (event.keyCode == 50&&event.ctrlKey)
15 {
16 var btn = document.getElementById("ctl00_cphCommonBodyColumn_pnlCargonExpand");
17
18 if (btn != event.srcElement)
19 {
20 btn.click();
21 return false;
22 }
23 }
24 if (event.keyCode == 51&&event.ctrlKey)
25 {
26 var btn = document.getElementById("ctl00_cphCommonBodyColumn_pnlServiceExpand");
27
28 if (btn != event.srcElement)
29 {
30 btn.click();
31 return false;
32 }
33 }
34 if (event.keyCode == 52&&event.ctrlKey)
35 {
36 var btn = document.getElementById("ctl00_cphCommonBodyColumn_pnlContactExpand");
37
38 if (btn != event.srcElement)
39 {
40 btn.click();
41 return false;
42 }
43 }
44 }
45
46</script>
47
48
注意里面的document.getElementById的ID是浏览页面的ID,可以通过查看-->源文件找到。