1
asp.net常用的javascript经典例子
2
Dropdownlist无刷新的例子。xml.
3
例如文本验证
!
4
下面是一个单选按纽前台不刷新的例子.有好的就往上贴
5
<
script language
=
"
javascript
"
>
6
function SetButton()
7
{
8 if(document.all.rdoByHuman.checked==true)
9
{
10 document.all.cboHrPut.disabled = "";
11 document.all.cboAnswerHr.disabled = "";
12
13
14 document.all.cboGroup.disabled = true;
15
16 }
17 if(document.all.rdoByGroup.checked==true)
18
{
19 document.all.cboHrPut.disabled = true;
20 document.all.cboAnswerHr.disabled = true;
21
22 document.all.cboGroup.disabled = "";
23
24
25
26 }
27 }
28
</
script
>
29
30
31
<
asp:RadioButton id
=
"
rdoByHuman
"
onclick
=
"
SetButton();
"
runat
=
"
server
"
GroupName
=
"
TotalGroup
"
Checked
=
"
True
"
Text
=
"
按人员
"
></
asp:RadioButton
>
32
e.Item.Attributes.Add(
"
onmouseOver
"
,
"
this.style.backgroundColor='#dee3e7'
"
);
//
鼠标移上去的颜色
33
e.Item.Attributes.Add(
"
onmouseOut
"
,
"
this.style.backgroundColor='white'
"
);
34
e.Item.Cells[
2
].Attributes.Add(
"
onmouseOver
"
,
"
this.style.backgroundColor='red'
"
);
35
e.Item.Cells[
2
].Attributes.Add(
"
onmouseOut
"
,
"
this.style.backgroundColor='white'
"
);
//
指定某列的颜色
36
e.Item.Cells[
3
].Style[
"
cursor
"
]
=
"
hand
"
;
37
e.Item.Cells[
4
].Attributes.Add(
"
onclick
"
,
"
alert('你惦记的ID 是:
"
+
e.Item.Cells[
4
].Text
+
"
');
"
);
//
指定显示字段
38
e.Item.Cells[
1
].Attributes.Add(
"
title
"
,
"
'红孩是未解决的,蓝精灵是已解决的!'
"
+
e.Item.Cells[
0
].Text.ToString());
//
显示title
39
e.Item.Cells[
0
].Attributes.Add(
"
onclick
"
,
"
window.open('xinxiForm.aspx?idmain=
"
+
e.Item.Cells[
0
].Text
+
"
','','ToolBar=no,width=260,height=200');
"
);
40
41
42
屏闭一些键:
43
44
function KeyDown()
{ //屏蔽鼠标右键、Ctrl+n、shift+F10、F5刷新、退格键
45 //alert("ASCII代码是:"+event.keyCode);
46 if ((window.event.altKey)&&
47 ((window.event.keyCode==37)|| //屏蔽 Alt+ 方向键 ←
48 (window.event.keyCode==39)))
{ //屏蔽 Alt+ 方向键 →
49 alert("不准你使用ALT+方向键前进或后退网页!");
50 event.returnValue=false;
51 }
52 if ((event.keyCode==8) || //屏蔽退格删除键
53 (event.keyCode==116)|| //屏蔽 F5 刷新键
54 (event.keyCode==112)|| //屏蔽 F1 刷新键
55 (event.ctrlKey && event.keyCode==82))
{ //Ctrl + R
56 event.keyCode=0;
57 event.returnValue=false;
58 }
59 if ((event.ctrlKey)&&(event.keyCode==78)) //屏蔽 Ctrl+n
60 event.returnValue=false;
61 if ((event.shiftKey)&&(event.keyCode==121)) //屏蔽 shift+F10
62 event.returnValue=false;
63 if (window.event.srcElement.tagName == "A" && window.event.shiftKey)
64 window.event.returnValue = false; //屏蔽 shift 加鼠标左键新开一网页
65 if ((window.event.altKey)&&(window.event.keyCode==115))
{ //屏蔽Alt+F4
66 window.showModelessDialog("about:blank","","dialogWidth:1px;dialogheight:1px");
67 return false;}
68}
69
1
. oncontextmenu
=
"
window.event.returnvalue=false
"
将彻底屏蔽鼠标右键
70
2
.
<
body onselectstart
=
"
return false
"
>
取消选取、防止复制
71
3
. onpaste
=
"
return false
"
不准粘贴
72
4
. oncopy
=
"
return false;
"
oncut
=
"
return false;
"
防止复制;防止剪切
73
5
.
<
link rel
=
"
Shortcut Icon
"
href
=
"
favicon.ico
"
>
IE地址栏前换成自己的图标
74
6
.
<
link rel
=
"
Bookmark
"
href
=
"
favicon.ico
"
>
可以在收藏夹中显示出你的图标
75
7
.
<
input style
=
"
ime-mode:disabled
"
>
关闭输入法
76
77
8
. 永远都会带着框架
78
<
script language
=
"
javascript
"
><!--
79
if
(window
==
top)
80
top.location.href
=
"
frames.htm
"
; file:
//
frames.htm为框架网页
81
//
--></script>
82
83
9
. 防止被人frame
84
<
SCRIPT LANGUAGE
=
javascript
><!--
85
if
(top.location
!=
self.location)
86
top.location
=
self.location;
87
//
--></SCRIPT>
88
89
10
.
<
noscript
><
iframe src
=*
.html
></
iframe
></
noscript
>
网页将不能被另存为
90
91
92
使用鼠标拖动的层
93
<
BODY BGCOLOR
=
"
#FFFFFF
"
>
94
<
div onmousedown
=
"
style.cursor='move';startMove(this)
"
onmouseup
=
"
style.cursor='auto'
"
style
=
"
border:1px solid #AAAAAA;background-color:#EEEEEE;width:300;height:200;position;text-align:center;
"
>
可以使用鼠标拖动
</
div
>
95
<
script language
=
javascript
>
96
function startMove(objDiv)
97
{
98 document.attachEvent("onmousemove",moveDiv);
99 document.attachEvent("onmouseup",endMove);
100 document.attachEvent("onselectstart",selectNo);
101 document["moveDiv"] = objDiv;
102 document["startX"] = event.x;
103 document["startY"] = event.y;
104 document["oldX"] = objDiv.getBoundingClientRect().left;
105 document["oldY"] = objDiv.getBoundingClientRect().top;
106}
107
function moveDiv()
108
{
109 //try{
110 var obj = document["moveDiv"];
111 if(obj)
112
{
113 var l = document["oldX"];//obj.getBoundingClientRect().left;//obj.style.left// = 100//(event.x-document["startX"]);
114 var t = document["oldY"];//obj.getBoundingClientRect().top;//obj.style.top// = 100//(event.y-document["startY"]);
115 obj.style.position = "absolute";
116 obj.style.left = l + (event.x-document["startX"]);
117 obj.style.top = t + (event.y-document["startY"]);
118 }
119 //}catch(e){endMove();}
120}
121
function endMove()
122
{
123 document.detachEvent("onmousemove",moveDiv);
124 document.detachEvent("onmouseup",endMove);
125 document.detachEvent("onselectstart",selectNo);
126 document["moveDiv"] = null;
127 document["startX"] = null;
128 document["startY"] = null;
129}
130
function selectNo()
131
{ return false; }
132
</
script
>
133
</
BODY
>
134
135
136
/**/
/* 异步,动态的加载网页xml数据 */
137
//
实际运用有更改
138
function GetXml(objContainer,id)
{
139 var XmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
140 objContainer.innerHTML=StateXML(Config.loading)
141 objContainer.send="true"
142 XmlHttp.onreadystatechange=function()
{
143 if(XmlHttp.readyState==4)
{
144 if(XmlHttp.status==200)
{
145 var Xmldoc=XmlHttp.responseXML
146 if(Xmldoc.documentElement.hasChildNodes())
147 objContainer.innerHTML=Xmldoc.transformNode(xsldoc)
148 else
149 objContainer.innerHTML=StateXML(Config.loading)
150 }
151 else
152 objContainer.innerHTML=StateXML(Config.unavaible)
153 }
154 }
155 XmlHttp.open("get",Config.Service+'?id='+id+'&tem'+Math.random(),true)
156 XmlHttp.send()
157}
158
159
转载于:https://www.cnblogs.com/nuptjinlu/archive/2008/04/17/1158897.html
原文链接:https://blog.csdn.net/weixin_30342827/article/details/96346385
本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。
还没有人抢沙发呢~