Home  >  Article  >  Web Front-end  >  The essence of JavaScript usage skills (.net html_javascript skills

The essence of JavaScript usage skills (.net html_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:53:52956browse

(1). Confirm deletion usage:
1. BtnDel.Attributes.Add("onclick","return confirm('" "Confirm deletion?" "')");
2. linktempDelete.Attributes[" onclick"]="javascript:return confirm('" "Confirm deletion?" "');";
3. private void grdProject_ItemDataBound(object sender, DataGridItemEventArgs e)
4.
{
if ((e.Item.ItemType == ListItemType.Item) | (e.Item.ItemType == ListItemType.AlternatingItem))
{
// Delete the prompt part on the button
e.Item. Cells[10].Attributes.Add("onclick", "return confirm('Are you sure to delete?');");
}
}
5.


(2). Cross-language string replacement System.Text.RegularExpressions.Regex.Replace(str1,@" ]*>{1}","").Replace(" ",""). Replace("\","\").Replace("-","-").Replace("&","&").Replace("
",">").Replace("br ","n");
(3).Close the form
1.
this.btnClose.Attributes.Add("onclick", "window.close();return false;");
2. Jump to another page between closing this form
this.HyperLink1.NavigateUrl = "javascript:onclick=window.opener.location.assign
('" "index.aspx" "? &Func=Edit&AutoID=" intAutoid ');window.close();";
3. Close the parent form:
4. Close this pop-up form and refresh the parent page
this.Response.Write("
");
(4).Web MessageBox
1.
Response .Write("
");
2.
Response.Write("
");
3.
this.Page.RegisterStartupScript("ChiName","
");
(5). Add CheckBox control template column to DataGrid.
Please see: http://blog.csdn.net/chengking/archive/2005/10/08/497520.aspx
(6). window.open() method
Syntax: window.open(pageurl,name,parameters);
The open() method of window object is used to create a new window instance. The newly created window The appearance is specified by parameters: parameters. The document opened in the new window is specified by the parameter: pageurl. The system can access the window according to the name determined by the parameter: name.
The following table is the parameters parameter table:
Parameter Initial value Description
alwaysLowered yes/no The specified window is hidden under all windows.
alwaysRaised yes/no Specifies that the window floats above all windows.
dependent yes/no specifies that the opened window is a window of the parent window. and closes when the parent window closes.
directions yes/no Specifies whether the directory bar of Navigator 2 and 3 is visible in new windows.
height pixel value sets the pixel height of the new window.
hotkeys yes/no Set safe exit hotkeys in new windows without menu bar.
innerHeight pixel value sets the pixel height of the document in the new window.
innerWidth pixel value sets the pixel width of the document in the new window.
location yes/no specifies whether the location bar is visible in new windows.
menubar yes /no specifies whether the menu bar is visible in new windows.
outerHeight pixel value sets the pixel height of the window (including decorative borders).
outerWidth pixel value sets the pixel width of the window (including decorative borders).
resizable yes /no indicates whether the new window can be resized.
screenX pixel value sets the pixel length of the new window from the screen boundary.
screenY pixel value sets the pixel length of the new window from the upper border of the screen. scrollbars yes /no specifies whether the scroll bar is visible in new windows. titlebar yes /no specifies whether the menu title bar is visible in new windows. toolbar yes /no specifies whether the toolbar is visible in new windows. Width pixel value sets the pixel width of the window. <script>alert('"+"保存成功!"+"'); </script>z-look yes /no Contains an array of individual tags in the document.
fullscreen yes / no 打开的窗体是否进行全屏显示
left pixel value 设定新窗口距屏幕左方的距离
top pixel value 设定新窗口距屏幕上方的距离
例子:


window.open函数





(七).location对象
href 整个URL字符串.
protocol 含有URL第一部分的字符串,如http:
host 包含有URL中主机名:端口号部分的字符串.如//www.cenpok.net/server/
hostname 包含URL中主机名的字符串.如http://www.cenpok.net
port 包含URL中可能存在的端口号字符串.
pathname URL中"/"以后的部分.如~list/index.htm
hash "#"号(CGI参数)之后的字符串.
search "?"号(CGI参数)之后的字符串.
(八).按键捕捉
1.Ctrl+Enter按键捕捉方法



2.Alt加快捷键: Alt+A

(九).控制输入,非法字符不能输入到TextBox.
onkeypress="if (event.keyCode 57) event.returnValue = false;"
id="txtY_Revenue" style="TEXT-ALIGN: right" runat="server" Width="90%" MaxLength="12">

说明: 此方法控制TextBox只收数字:0~9 , 也自可以定义其它可输入字符,如改成: 65~123,只允许输入: a~z和A~Z 等.
[以下为收藏]
1>屏蔽功能类
1.1 屏蔽键盘所有键

1.2 屏蔽鼠标右键
在body标签里加上oncontextmenu=self.event.returnvalue=false
或者

function nocontextmenu()
{
if(document.all) {
event.cancelBubble=true;
event.returnvalue=false;
return false;
}
}
或者


1.3 屏蔽 Ctrl+N、Shift+F10、F5刷新、退格键

1.4屏蔽浏览器右上角“最小化”“最大化”“关闭”键

或者使用全屏打开页面

注:在body标签里加上onbeforeunload="javascript:return false"(使不能关闭窗口)
1.5屏蔽F5键

1.6屏蔽IE后退按钮
在你链接的时候用
1.7屏蔽主窗口滚动条
在body标签里加上 style="overflow-y:hidden"
1.8 屏蔽拷屏,不断地清空剪贴板
在body标签里加上onload="setInterval('clipboardData.setData(\'Text\',\'\')',100)"
1.9 屏蔽网站的打印功能

1.10 屏蔽IE6.0 图片上自动出现的保存图标
方法一:

方法二:
The essence of JavaScript usage skills (.net html_javascript skills
1.11 屏蔽页中所有的script

2>表单提交验证类
2.1 表单项不能为空

2.2 比较两个表单项的值是否相同

2.3 表单项只能为数字和"_",用于电话/银行帐号验证上,可扩展到域名注册等

2.4 表单项输入数值/长度限定

2.5 中文/英文/数字/邮件地址合法性判断

2.6 限定表单项不能输入的字符

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn