JavaScript函数小结
JS基础知识
/**********************
1:基础知识 1 创建脚本块 1: <script language=”JavaScript”>
2: JavaScript code goes here
3: </script> 2 隐藏脚本代码 1: <script language=”JavaScript”>
2: <!--
3: document.write(“Hello”);
4: // -->
5: </script> 在不支持JavaScript的浏览器中将不执行相关代码 3 浏览器不支持的时候显示 1: <noscript>
2: Hello to the non-JavaScript browser.
3: </noscript> 4 链接外部脚本文件 1: <script language=”JavaScript” src="/”filename.js"”></script> 5 注释脚本 1: // This is a comment
2: document.write(“Hello”); // This is a comment
3: /*
4: All of this
5: is a comment
6: */ 6 输出到浏览器 1: document.write(“<strong>Hello</strong>”); 7 定义变量 1: var myVariable = “some value”; 8 字符串相加 1: var myString = “String1” + “String2”; 9 字符串搜索 1: <script language=”JavaScript”>
2: <!--
3: var myVariable = “Hello there”;
4: var therePlace = myVariable.search(“there”);
5: document.write(therePlace);
6: // -->
7: </script> 10 字符串替换 1: thisVar.replace(“Monday”,”Friday”); 11 格式化字串 1: <script language=”JavaScript”>
2: <!--
3: var myVariable = “Hello there”;
4: document.write(myVariable.big() + “<br/>”);
5: document.write(myVariable.blink() + “<br/>”);
6: document.write(myVariable.bold() + “<br/>”);
7: document.write(myVariable.fixed() + “<br/>”);
8: document.write(myVariable.fontcolor(“red”) + “<br/>”);
9: document.write(myVariable.fontsize(“18pt”) + “<br/>”);
10: document.write(myVariable.italics() + “<br/>”);
11: document.write(myVariable.small() + “<br/>”);
12: document.write(myVariable.strike() + “<br/>”);
13: document.write(myVariable.sub() + “<br/>”);
14: document.write(myVariable.sup() + “<br/>”);
15: document.write(myVariable.toLowerCase() + “<br/>”);
16: document.write(myVariable.toUpperCase() + “<br/>”);
17:
18: var firstString = “My String”;
19: var finalString = firstString.bold().toLowerCase().fontcolor(“red”);
20: // -->
21: </script> 12 创建数组 1: <script language=”JavaScript”>
2: <!--
3: var myArray = new Array(5);
4: myArray[0] = “First Entry”;
5: myArray[1] = “Second Entry”;
6: myArray[2] = “Third Entry”;
7: myArray[3] = “Fourth Entry”;
8: myArray[4] = “Fifth Entry”;
9: var anotherArray = new Array(“First Entry”,”Second Entry”,”Third Entry”,”Fourth Entry”,”Fifth Entry”);
10: // -->
11: </script> 13 数组排序 1: <script language=”JavaScript”>
2: <!--
3: var myArray = new Array(5);
4: myArray[0] = “z”;
5: myArray[1] = “c”;
6: myArray[2] = “d”;
7: myArray[3] = “a”;
8: myArray[4] = “q”;
9: document.write(myArray.sort());
10: // -->
11: </script> 14 分割字符串 1: <script language=”JavaScript”>
2: <!--
3: var myVariable = “a,b,c,d”;
4: var stringArray = myVariable.split(“,”);
5: document.write(stringArray[0]);
6: document.write(stringArray[1]);
7: document.write(stringArray[2]);
8: document.write(stringArray[3]);
9: // -->
10: </script> 15 弹出警告信息 1: <script language=”JavaScript”>
2: <!--
3: window.alert(“Hello”);
4: // -->
5: </script> 16 弹出确认框 1: <script language=”JavaScript”>
2: <!--
3: var result = window.confirm(“Click OK to continue”);
4: // -->
5: </script> 17 定义函数 1: <script language=”JavaScript”>
2: <!--
3: function multiple(number1,number2) {
4: var result = number1 * number2;
5: return result;
6: }
7: // -->
8: </script> 18 调用JS函数 1: <a href=”#” onClick=”functionName()”>Link text</a>
2: <a href="/”javascript:functionName"()”>Link text</a> 19 在页面加载完成后执行函数 1: <body onLoad=”functionName();”>
2: Body of the page
3: </body> 20 条件判断 1: <script>
2: <!--
3: var userChoice = window.confirm(“Choose OK or Cancel”);
4: var result = (userChoice == true) ? “OK” : “Cancel”;
5: document.write(result);
6: // -->
7: </script>
21 指定次数循环 1: <script>
2: <!--
3: var myArray = new Array(3);
4: myArray[0] = “Item 0”;
5: myArray[1] = “Item 1”;
6: myArray[2] = “Item 2”;
7: for (i = 0; i < myArray.length; i++) {
8: document.write(myArray[i] + “<br/>”);
9: }
10: // -->
11: </script> 22 设定将来执行 1: <script>
2: <!--
3: function hello() {
4: window.alert(“Hello”);
5: }
6: window.setTimeout(“hello()”,5000);
7: // -->
8: </script> 23 定时执行函数 1: <script>
2: <!--
3: function hello() {
4: window.alert(“Hello”);
5: window.setTimeout(“hello()”,5000);
6: }
7: window.setTimeout(“hello()”,5000);
8: // -->
9: </script> 24 取消定时执行 1: <script>
2: <!--
3: function hello() {
4: window.alert(“Hello”);
5: }
6: var myTimeout = window.setTimeout(“hello()”,5000);
7: window.clearTimeout(myTimeout);
8: // -->
9: </script> 25 在页面卸载时候执行函数 1: <body onUnload=”functionName();”>
2: Body of the page
3: </body> JavaScript就这么回事2:浏览器输出 26 访问document对象 1: <script language=”JavaScript”>
2: var myURL = document.URL;
3: window.alert(myURL);
4: </script> 27 动态输出HTML 1: <script language=”JavaScript”>
2: document.write(“<p>Here’s some information about this document:</p>”);
3: document.write(“<ul>”);
4: document.write(“<li>Referring Document: “ + document.referrer + “</li>”);
5: document.write(“<li>Domain: “ + document.domain + “</li>”);
6: document.write(“<li>URL: “ + document.URL + “</li>”);
7: document.write(“</ul>”);
8: </script> 28 输出换行 1: document.writeln(“<strong>a</strong>”);
2: document.writeln(“b”); 29 输出日期 1: <script language=”JavaScript”>
2: var thisDate = new Date();
3: document.write(thisDate.toString());
4: </script> 30 指定日期的时区 1: <script language=”JavaScript”>
2: var myOffset = -2;
3: var currentDate = new Date();
4: var userOffset = currentDate.getTimezoneOffset()/60;
5: var timeZoneDifference = userOffset - myOffset;
6: currentDate.setHours(currentDate.getHours() + timeZoneDifference);
7: document.write(“The time and date in Central Europe is: “ + currentDate.toLocaleString());
8: </script> 31 设置日期输出格式 1: <script language=”JavaScript”>
2: var thisDate = new Date();
3: var thisTimeString = thisDate.getHours() + “:” + thisDate.getMinutes();
4: var thisDateString = thisDate.getFullYear() + “/” + thisDate.getMonth() + “/” + thisDate.getDate();
5: document.write(thisTimeString + “ on “ + thisDateString);
6: </script> 32 读取URL参数 1: <script language=”JavaScript”>
2: var urlParts = document.URL.split(“?”);
3: var parameterParts = urlParts[1].split(“&”);
4: for (i = 0; i < parameterParts.length; i++) {
5: var pairParts = parameterParts[i].split(“=”);
6: var pairName = pairParts[0];
7: var pairValue = pairParts[1];
8: document.write(pairName + “ :“ +pairValue );
9: }
10: </script> 你还以为HTML是无状态的么? 33 打开一个新的document对象 1: <script language=”JavaScript”>
2: function newDocument() {
3: document.open();
4: document.write(“<p>This is a New Document.</p>”);
5: document.close();
6: }
7: </script> 34 页面跳转 1: <script language=”JavaScript”>
2: window.location = “http://www.liu21st.com/”;
3: </script> 35 添加网页加载进度窗口 1: <html>
2: <head>
3: <script language=’javaScript’>
4: var placeHolder = window.open(’holder.html’,’placeholder’,’width=200,height=200’);
5: </script>
6: <title>The Main Page</title>
7: </head>
8: <body onLoad=’placeHolder.close()’>
9: <p>This is the main page</p>
10: </body>
11: </html> JavaScript就这么回事3:图像 36 读取图像属性 1: <img src="/”image1.jpg"” name=”myImage”>
2: <a href=”# ” onClick=”window.alert(document.myImage.width)”>Width</a>
3: 37 动态加载图像 1: <script language=”JavaScript”>
2: myImage = new Image;
3: myImage.src = “Tellers1.jpg”;
4: </script> 38 简单的图像替换 1: <script language=”JavaScript”>
2: rollImage = new Image;
3: rollImage.src = “rollImage1.jpg”;
4: defaultImage = new Image;
5: defaultImage.src = “image1.jpg”;
6: </script>
7: <a href="/”myUrl"” onMouseOver=”document.myImage.src = rollImage.src;”
8: onMouseOut=”document.myImage.src = defaultImage.src;”>
9: <img src="/”image1.jpg"” name=”myImage” width=100 height=100 border=0> 39 随机显示图像 1: <script language=”JavaScript”>
2: var imageList = new Array;
3: imageList[0] = “image1.jpg”;
4: imageList[1] = “image2.jpg”;
5: imageList[2] = “image3.jpg”;
6: imageList[3] = “image4.jpg”;
7: var imageChoice = Math.floor(Math.random() * imageList.length);
8: document.write(‘<img src=”’ + imageList[imageChoice] + ‘“>’);
9: </script> 40 函数实现的图像替换 1: <script language=”JavaScript”>
2: var source = 0;
3: var replacement = 1;
4: function createRollOver(originalImage,replacementImage) {
5: var imageArray = new Array;
6: imageArray[source] = new Image;
7: imageArray[source].src = originalImage;
8: imageArray[replacement] = new Image;
9: imageArray[replacement].src = replacementImage;
10: return imageArray;
11: }
12: var rollImage1 = createRollOver(“image1.jpg”,”rollImage1.jpg”);
13: </script>
14: <a href=”#” onMouseOver=”document.myImage1.src = rollImage1[replacement].src;”
15: onMouseOut=”document.myImage1.src = rollImage1[source].src;”>
16: <img src="/”image1.jpg"” width=100 name=”myImage1” border=0>
17: </a> 41 创建幻灯片 1: <script language=”JavaScript”>
2: var imageList = new Array;
3: imageList[0] = new Image;
4: imageList[0].src = “image1.jpg”;
5: imageList[1] = new Image;
6: imageList[1].src = “image2.jpg”;
7: imageList[2] = new Image;
8: imageList[2].src = “image3.jpg”;
9: imageList[3] = new Image;
10: imageList[3].src = “image4.jpg”;
11: function slideShow(imageNumber) {
12: document.slideShow.src = imageList[imageNumber].src;
13: imageNumber += 1;
14: if (imageNumber < imageList.length) {
15: window.setTimeout(“slideShow(“ + imageNumber + “)”,3000);
16: }
17: }
18: </script>
19: </head>
20: <body onLoad=”slideShow(0)”>
21: <img src="/”image1.jpg"” width=100 name=”slideShow”> 42 随机广告图片 1: <script language=”JavaScript”>
2: var imageList = new Array;
3: imageList[0] = “image1.jpg”;
4: imageList[1] = “image2.jpg”;
5: imageList[2] = “image3.jpg”;
6: imageList[3] = “image4.jpg”;
7: var urlList = new Array;
8: urlList[0] = “http://some.host/”;
9: urlList[1] = “http://another.host/”;
10: urlList[2] = “http://somewhere.else/”;
11: urlList[3] = “http://right.here/”;
12: var imageChoice = Math.floor(Math.random() * imageList.length);
13: document.write(‘<a href=”’ + urlList[imageChoice] + ‘“><img src=”’ + imageList[imageChoice] + ‘“></a>’);
14: </script> JavaScript就这么回事4:表单 43 表单构成 1: <form method=”post” action=”target.html” name=”thisForm”>
2: <input type=”text” name=”myText”>
3: <select name=”mySelect”>
4: <option value=”1”>First Choice</option>
5: <option value=”2”>Second Choice</option>
6: </select>
7: <br/>
8: <input type=”submit” value=”Submit Me”>
9: </form> 44 访问表单中的文本框内容 1: <form name=”myForm”>
2: <input type=”text” name=”myText”>
3: </form>
4: <a href=’#’ onClick=’window.alert(document.myForm.myText.value);’>Check Text Field</a> 45 动态复制文本框内容 1: <form name=”myForm”>
2: Enter some Text: <input type=”text” name=”myText”><br/>
3: Copy Text: <input type=”text” name=”copyText”>
4: </form>
5: <a href=”#” onClick=”document.myForm.copyText.value =
6: document.myForm.myText.value;”>Copy Text Field</a> 46 侦测文本框的变化 1: <form name=”myForm”>
2: Enter some Text: <input type=”text” name=”myText” onChange=”alert(this.value);”>
3: </form> 47 访问选中的Select 1: <form name=”myForm”>
2: <select name=”mySelect”>
3: <option value=”First Choice”>1</option>
4: <option value=”Second Choice”>2</option>
5: <option value=”Third Choice”>3</option>
6: </select>
7: </form>
8: <a href=’#’ onClick=’alert(document.myForm.mySelect.value);’>Check Selection List</a> 48 动态增加Select项 1: <form name=”myForm”>
2: <select name=”mySelect”>
3: <option value=”First Choice”>1</option>
4: <option value=”Second Choice”>2</option>
5: </select>
6: </form>
7: <script language=”JavaScript”>
8: document.myForm.mySelect.length++;
9: document.myForm.mySelect.options[document.myForm.mySelect.length - 1].text = “3”;
10: document.myForm.mySelect.options[document.myForm.mySelect.length - 1].value = “Third Choice”;
11: </script> 49 验证表单字段 1: <script language=”JavaScript”>
2: function checkField(field) {
3: if (field.value == “”) {
4: window.alert(“You must enter a value in the field”);
5: field.focus();
6: }
7: }
8: </script>
9: <form name=”myForm” action=”target.html”>
10: Text Field: <input type=”text” name=”myField”onBlur=”checkField(this)”>
11: <br/><input type=”submit”>
12: </form> 50 验证Select项 1: function checkList(selection) {
2: if (selection.length == 0) {
3: window.alert(“You must make a selection from the list.”);
4: return false;
5: }
6: return true;
7: } 51 动态改变表单的action 1: <form name=”myForm” action=”login.html”>
2: Username: <input type=”text” name=”username”><br/>
3: Password: <input type=”password” name=”password”><br/>
4: <input type=”button” value=”Login” onClick=”this.form.submit();”>
5: <input type=”button” value=”Register” onClick=”this.form.action = ‘register.html’; this.form.submit();”>
6: <input type=”button” value=”Retrieve Password” onClick=”this.form.action = ‘password.html’; this.form.submit();”>
7: </form> 52 使用图像按钮 1: <form name=”myForm” action=”login.html”>
2: Username: <input type=”text” name=”username”><br/>
3: Password: <input type=”password”name=”password”><br/>
4: <input type=”image” src="/”login.gif"” value=”Login”>
5: </form>
6: 53 表单数据的加密 1: <SCRIPT LANGUAGE=’JavaScript’>
2: <!--
3: function encrypt(item) {
4: var newItem = ’’;
5: for (i=0; i < item.length; i++) {
6: newItem += item.charCodeAt(i) + ’.’;
7: }
8: return newItem;
9: }
10: function encryptForm(myForm) {
11: for (i=0; i < myForm.elements.length; i++) {
12: myForm.elements[i].value = encrypt(myForm.elements[i].value);
13: }
14: }
15:
16: //-->
17: </SCRIPT>
18: <form name=’myForm’ onSubmit=’encryptForm(this); window.alert(this.myField.value);’>
19: Enter Some Text: <input type=text name=myField><input type=submit>
20: </form> JavaScript就这么回事5:窗口和框架 54 改变浏览器状态栏文字提示 1: <script language=”JavaScript”>
2: window.status = “A new status message”;
3: </script> 55 弹出确认提示框 1: <script language=”JavaScript”>
2: var userChoice = window.confirm(“Click OK or Cancel”);
3: if (userChoice) {
4: document.write(“You chose OK”);
5: } else {
6: document.write(“You chose Cancel”);
7: }
8: </script> 56 提示输入 1: <script language=”JavaScript”>
2: var userName = window.prompt(“Please Enter Your Name”,”Enter Your Name Here”);
3: document.write(“Your Name is “ + userName);
4: </script> 57 打开一个新窗口 1: //打开一个名称为myNewWindow的浏览器新窗口
2: <script language=”JavaScript”>
3: window.open(“http://www.liu21st.com/”,”myNewWindow”);
4: </script> 58 设置新窗口的大小 1: <script language=”JavaScript”>
2: window.open(“http://www.liu21st.com/”,”myNewWindow”,’height=300,width=300’);
3: </script> 59 设置新窗口的位置 1: <script language=”JavaScript”>
2: window.open(“http://www.liu21st.com/”,”myNewWindow”,’height=300,width=300,left=200,screenX=200,top=100,screenY=100’);
3: </script> 60 是否显示工具栏和滚动栏 1: <script language=”JavaScript”>
2: window.open(“http: 61 是否可以缩放新窗口的大小 1: <script language=”JavaScript”>
2: window.open(’http://www.liu21st.com/’ , ’myNewWindow’, ’resizable=yes’ );</script> 62 加载一个新的文档到当前窗口 1: <a href=’#’ onClick=’document.location = ’125a.html’;’ >Open New Document</a> 63 设置页面的滚动位置 1: <script language=”JavaScript”>
2: if (document.all) { //如果是IE浏览器则使用scrollTop属性
3: document.body.scrollTop = 200;
4: } else { //如果是NetScape浏览器则使用pageYOffset属性
5: window.pageYOffset = 200;
6: }</script> 64 在IE中打开全屏窗口 1: <a href=’#’ onClick=”window.open(’http://www.juxta.com/’,’newWindow’,’fullScreen=yes’);”>Open a full-screen window</a> 65 新窗口和父窗口的操作 1: <script language=”JavaScript”>
2: //定义新窗口
3: var newWindow = window.open(“128a.html”,”newWindow”);
4: newWindow.close(); //在父窗口中关闭打开的新窗口
5: </script>
6: 在新窗口中关闭父窗口
7: window.opener.close() 66 往新窗口中写内容 1: <script language=”JavaScript”>
2: var newWindow = window.open(“”,”newWindow”);
3: newWindow.document.open();
4: newWindow.document.write(“This is a new window”);
5: newWIndow.document.close();
6: </script> 67 加载页面到框架页面 1: <frameset cols=”50%,*”>
2: <frame name=”frame1” src="/”135a.html"”>
3: <frame name=”frame2” src="/”about:blank"”>
4: </frameset>
5: 在frame1中加载frame2中的页面
6: parent.frame2.document.location = “135b.html”; 68 在框架页面之间共享脚本
如果在frame1中html文件中有个脚本 1: function doAlert() {
2: window.alert(“Frame 1 is loaded”);
3: } 那么在frame2中可以如此调用该方法 1: <body onLoad=”parent.frame1.doAlert();”>
2: This is frame 2.
3: </body> 69 数据公用
可以在框架页面定义数据项,使得该数据可以被多个框架中的页面公用 1: <script language=”JavaScript”>
2: var persistentVariable = “This is a persistent value”;
3: </script>
4: <frameset cols=”50%,*”>
5: <frame name=”frame1” src="/”138a.html"”>
6: <frame name=”frame2” src="/”138b.html"”>
7: </frameset> 这样在frame1和frame2中都可以使用变量persistentVariable 70 框架代码库
根据以上的一些思路,我们可以使用一个隐藏的框架页面来作为整个框架集的代码库 1: <frameset cols=”0,50%,*”>
2: <frame name=”codeFrame” src="/”140code.html"”>
3: <frame name=”frame1” src="/”140a.html"”>
4: <frame name=”frame2” src="/”140b.html"”>
5: </frameset> *************/
JS常用语句
/*
1.document.write(""); 输出语句
2.JS中的注释为//
3.传统的HTML文档顺序是:
document->html->(head,body)
4.一个浏览器窗口中的DOM顺序是:
window->(navigator,screen,history,location,document)
5.得到表单中元素的名称和值:
document.getElementById("表单中元素的ID号").name(或value)
6.一个小写转大写的JS:
document.getElementById("output").value=document.getElementById("input").value.toUpperCase();
7.JS中的值类型:
String,Number,Boolean,Null,Object,Function
8.JS中的字符型转换成数值型:
parseInt(),parseFloat()
9.JS中的数字转换成字符型:
("" 变量)
10.JS中的取字符串长度是:
(length)
11.JS中的字符与字符相连接使用+号.
12.JS中的比较操作符有:
==等于,!=不等于,>,>=,<.<=
13.JS中声明变量使用:
var来进行声明
14.JS中的判断语句结构:
if(condition){}else{}
15.JS中的循环结构:
for([initial expression];[condition];[upadte expression]) {inside loop}
16.循环中止的命令是:
break
17.JS中的函数定义:
function functionName([parameter],…){statement[s]}
18.当文件中出现多个form表单时.可以用document.forms[0],document.forms[1]来代替.
19.窗口:
打开窗口window.open(), 关闭一个窗口:window.close(), 窗口本身:self
20.状态栏的设置:
window.status="字符";
21.弹出提示信息:
window.alert("字符");
22.弹出确认框:
window.confirm();
23.弹出输入提示框:
window.prompt();
24.指定当前显示链接的位置:
window.location.href="URL"
25.取出窗体中的所有表单的数量:
document.forms.length
26.关闭文档的输出流:
document.close();
27.字符串追加连接符: =
28.创建一个文档元素:
document.createElement(),document.createTextNode()
29.得到元素的方法:
document.getElementById()
30.设置表单中所有文本型的成员的值为空:
var form = window.document.forms[0]
for (var i = 0; i<form.elements.length;i ){
if (form.elements.type == "text"){
form.elements.value = "";
}
}
31.复选按钮在JS中判断是否选中:
document.forms[0].checkThis.checked
(checked属性代表为是否选中返回TRUE或FALSE)
32.单选按钮组(单选按钮的名称必须相同):
取单选按钮组的长度document.forms[0].groupName.length
33.单选按钮组判断是否被选中也是用checked.
34.下拉列表框的值:
document.forms[0].selectName.options[n].value
(n有时用下拉列表框名称加上.selectedIndex来确定被选中的值)
35.字符串的定义:
var myString = new String("This is lightsword");
36.字符串转成大写:
string.toUpperCase(); 字符串转成小写:string.toLowerCase();
37.返回字符串2在字符串1中出现的位置:
String1.indexOf("String2")!=-1则说明没找到.
38.取字符串中指定位置的一个字符:
StringA.charAt(9);
39.取出字符串中指定起点和终点的子字符串:
stringA.substring(2,6);
40.数学函数:
Math.PI(返回圆周率),Math.SQRT2(返回开方),Math.max(value1,value2)返回两个数中的
最在值,Math.pow(value1,10)返回value1的十次方,Math.round(value1)四舍五入函数,
Math.floor(Math.random()*(n 1))返回随机数
41.定义日期型变量:
var today = new Date();
42.日期函数列表:
dateObj.getTime()得到时间,dateObj.getYear()得到年份,dateObj.getFullYear()得到四位的年份,
dateObj.getMonth()得到月份,dateObj.getDate()得到日,dateObj.getDay()得到日期几,
dateObj.getHours()得到小时,dateObj.getMinutes()得到分,dateObj.getSeconds()得到秒,
dateObj.setTime(value)设置时间,dateObj.setYear(val)设置年,
dateObj.setMonth(val)设置月,dateObj.setDate(val)设置日,
dateObj.setDay(val)设置星期几,dateObj.setHours设置小时,dateObj.setMinutes(val)设置分,
dateObj.setSeconds(val)设置秒 [注意:此日期时间从0开始计]
43.FRAME的表示方式:
[window.]frames[n].ObjFuncVarName,frames["frameName"].ObjFuncVarName,frameName.ObjFuncVarName
44.parent代表父亲对象,top代表最顶端对象
45.打开子窗口的父窗口为:opener
46.表示当前所属的位置:this
47.当在超链接中调用JS函数时用:(javascript :)来开头后面加函数名
48.在老的浏览器中不执行此JS:<!– //–>
49.引用一个文件式的JS:<script type="text/javascript" src="aaa.js"></script>
50.指定在不支持脚本的浏览器显示的HTML:<noscript></noscript>
51.当超链和onCLICK事件都有时,则老版本的浏览器转向a.html,否则转向b.html.
例:<a href="a.html" onclick="location.href='b.html';return false">dfsadf</a>
52.JS的内建对象有:
Array,Boolean,Date,Error,EvalError,
Function,Math,Number,Object,RangeError,ReferenceError,
RegExp,String,SyntaxError,TypeError,URIError
53.JS中的换行:\n
54.窗口全屏大小:
<script>function fullScreen(){ this.moveTo(0,0);this.outerWidth=screen.availWidth;
this.outerHeight=screen.availHeight;}window.maximize=fullScreen;</script>
55.JS中的all代表其下层的全部元素
56.JS中的焦点顺序:document.getElementByid("表单元素").tabIndex = 1
57.innerHTML的值是表单元素的值:
如<p id="para">"how are <em>you</em>"</p>,则innerHTML的值就是:how are <em>you</em>
58.innerTEXT的值和上面的一样,只不过不会把<em>这种标记显示出来.
59.contentEditable可设置元素是否可被修改,isContentEditable返回是否可修改的状态.
60.isDisabled判断是否为禁止状态.disabled设置禁止状态
61.length取得长度,返回整型数值
62.addBehavior()是一种JS调用的外部函数文件其扩展名为.htc
63.window.focus()使当前的窗口在所有窗口之前.
64.blur()指失去焦点.与FOCUS()相反.
65.select()指元素为选中状态.
66.防止用户对文本框中输入文本:
onfocus="this.blur()"
67.取出该元素在页面中出现的数量:
document.all.tags("div(或其它HTML标记符)").length
68.JS中分为两种窗体输出:模态和非模态.
window.showModaldialog(),window.showModeless()
69.状态栏文字的设置:
window.status='文字',默认的状态栏文字设置:window.defaultStatus = '文字.';
70.添加到收藏夹:
external.AddFavorite("http://www.dannyg.com";,"jaskdlf");
71.JS中遇到脚本错误时不做任何操作:
window.onerror = doNothing; 指定错误句柄的语法为:window.onerror = handleError;
72.JS中指定当前打开窗口的父窗口:
window.opener,支持opener.opener…的多重继续.
73.JS中的self指的是当前的窗口
74.JS中状态栏显示内容:window.status="内容"
75.JS中的top指的是框架集中最顶层的框架
76.JS中关闭当前的窗口:window.close();
77.JS中提出是否确认的框:if(confirm("Are you sure?")){alert("ok");}else{alert("Not Ok");}
78.JS中的窗口重定向:window.navigate("http://www.sina.com.cn";);
79.JS中的打印:window.print()
80.JS中的提示输入框:window.prompt("message","defaultReply");
81.JS中的窗口滚动条:window.scroll(x,y)
82.JS中的窗口滚动到位置:window.scrollby
83.JS中设置时间间隔:setInterval("expr",msecDelay)或setInterval(funcRef,msecDelay)或setTimeout
84.JS中的模态显示在IE4 行,在NN中不行:showModalDialog("URL"[,arguments][,features]);
85.JS中的退出之前使用的句柄:
function verifyClose(){event.returnValue="we really like you and hope you will stay longer.";}} window.=verifyClose;
86.当窗体第一次调用时使用的文件句柄:onload()
87.当窗体关闭时调用的文件句柄:onunload()
88.window.location的属性:
protocol(http:),hostname(www.example.com),port(80),host(www.example.com:80),
pathname("/a/a.html"),hash("#giantGizmo",指跳转到相应的锚记),href(全部的信息)
89.window.location.reload()刷新当前页面.
90.window.history.back()返回上一页,window.history.forward()返回下一页,
window.history.go(返回第几页,也可以使用访问过的URL)
91.document.write()不换行的输出,document.writeln()换行输出
92.document.body.noWrap=true;防止链接文字折行.
93.变量名.charAt(第几位),取该变量的第几位的字符.
94."abc".charCodeAt(第几个),返回第几个字符的ASCii码值.
95.字符串连接:string.concat(string2),或用 =进行连接
96.变量.indexOf("字符",起始位置),返回第一个出现的位置(从0开始计算)
97.string.lastIndexOf(searchString[,startIndex])最后一次出现的位置.
98.string.match(regExpression),判断字符是否匹配.
99.string.replace(regExpression,replaceString)替换现有字符串.
100.string.split(分隔符)返回一个数组存储值.
101.string.substr(start[,length])取从第几位到指定长度的字符串.
102.string.toLowerCase()使字符串全部变为小写.
103.string.toUpperCase()使全部字符变为大写.
104.parseInt(string[,radix(代表进制)])强制转换成整型.
105.parseFloat(string[,radix])强制转换成浮点型.
106.isNaN(变量):测试是否为数值型.
107.定义常量的关键字:const,定义变量的关键字:var */
JS常用函数
//****************************************************************
//* 名 称:DataLength
//* 功 能:计算数据的长度
//* 入口参数:fData:需要计算的数据
//* 出口参数:返回fData的长度(Unicode长度为2,非Unicode长度为1)
//*****************************************************************
function DataLength(fData)
{
var intLength=0
for (var i=0;i {
if ((fData.charCodeAt(i) < 0) (fData.charCodeAt(i) > 255))
intLength=intLength+2
else
intLength=intLength+1
}
return intLength
} //****************************************************************
//* 名 称:DataLength
//* 功 能:计算数据的长度
//* 入口参数:fData:需要计算的数据
//* 出口参数:返回fData的长度(Unicode长度为2,非Unicode长度为1)
//*****************************************************************
function DataLength(fData)
{
var intLength=0
for (var i=0;i {
if ((fData.charCodeAt(i) < 0) (fData.charCodeAt(i) > 255))
intLength=intLength+2
else
intLength=intLength+1
}
return intLength
} //****************************************************************
//* 名 称:IsEmpty
//* 功 能:判断是否为空
//* 入口参数:fData:要检查的数据
//* 出口参数:True:空
//* False:非空
//*****************************************************************
function IsEmpty(fData)
{
return ((fData==null) (fData.length==0) )
} //****************************************************************
//* 名 称:IsDigit
//* 功 能:判断是否为数字
//* 入口参数:fData:要检查的数据
//* 出口参数:True:是0到9的数字
//* False:不是0到9的数字
//*****************************************************************
function IsDigit(fData)
{
return ((fData>="0") && (fData<="9"))
} //****************************************************************
//* 名 称:IsInteger
//* 功 能:判断是否为正整数
//* 入口参数:fData:要检查的数据
//* 出口参数:True:是整数,或者数据是空的
//* False:不是整数
//*****************************************************************
function IsInteger(fData)
{
//如果为空,返回true
if (IsEmpty(fData))
return true
if ((isNaN(fData)) (fData.indexOf(".")!=-1) (fData.indexOf("-")!=-1))
return false return true
} //****************************************************************
//* 名 称:IsEmail
//* 功 能:判断是否为正确的Email地址
//* 入口参数:fData:要检查的数据
//* 出口参数:True:正确的Email地址,或者空
//* False:错误的Email地址
//*****************************************************************
function IsEmail(fData)
{
if (IsEmpty(fData))
return true
if (fData.indexOf("@")==-1)
return false
var NameList=fData.split("@");
if (NameList.length!=2)
return false
if (NameList[0].length<1 )
return false
if (NameList[1].indexOf(".")<=0)
return false
if (fData.indexOf("@")>fData.indexOf("."))
return false
if (fData.indexOf(".")==fData.length-1)
return false return true
} //****************************************************************
//* 名 称:IsPhone
//* 功 能:判断是否为正确的电话号码(可以含"()"、"()"、"+"、"-"和空格)
//* 入口参数:fData:要检查的数据
//* 出口参数:True:正确的电话号码,或者空
//* False:错误的电话号码
//* 错误信息:
//*****************************************************************
function IsPhone(fData)
{
var str;
var fDatastr="";
if (IsEmpty(fData))
return true
for (var i=0;i {
str=fData.substring(i,i+1);
if (str!="(" && str!=")" && str!="(" && str!=")" && str!="+" && str!="-" && str!=" ")
fDatastr=fDatastr+str;
}
//alert(fDatastr);
if (isNaN(fDatastr))
return false
return true
} //****************************************************************
//* 名 称:IsPlusNumeric
//* 功 能:判断是否为正确的正数(可以含小数部分)
//* 入口参数:fData:要检查的数据
//* 出口参数:True:正确的正数,或者空
//* False:错误的正数
//* 错误信息:
//*****************************************************************
function IsPlusNumeric(fData)
{
if (IsEmpty(fData))
return true
if ((isNaN(fData)) (fData.indexOf("-")!=-1))
return false
return true
} //****************************************************************
//* 名 称:IsNumeric
//* 功 能:判断是否为正确的数字(可以为负数,小数)
//* 入口参数:fData:要检查的数据
//* 出口参数:True:正确的数字,或者空
//* False:错误的数字
//* 错误信息:
//*****************************************************************
function IsNumeric(fData)
{
if (IsEmpty(fData))
return true
if (isNaN(fData))
return false return true
} //****************************************************************
//* 名 称:IsIntegerInRange
//* 功 能:判断一个数字是否在指定的范围内
//* 入口参数:fInput:要检查的数据
//* fLower:检查的范围下限,如果没有下限,请用null
//* fHigh:检查的上限,如果没有上限,请用null
//* 出口参数:True:在指定的范围内
//* False:超出指定范围
//*****************************************************************
function IsIntegerInRange(fInput,fLower,fHigh)
{
if (fLower==null)
return (fInput<=fHigh)
else if (fHigh==null)
return (fInput>=fLower)
else
return ((fInput>=fLower) && (fInput<=fHigh))
}
弹窗代码
// JavaScript Document
<!--
var nid=0;
var tid=431;
var mid=947;
var full=1;
var popDialogOptions = "dialogWidth:800px; dialogHeight:600px; dialogTop:0px; dialogLeft:0px; edge:Raised; center:0; help:0; resizable:1; scroll:1; status:0";
var popWindowOptions = "scrollbars=1,menubar=0,toolbar=0,location=0,personalbar=0,status=0,resizable=1";
var doexit = true;
var usePopDialog = true;
var isUsingSpecial = false; function loadpopups(){
if(doexit && !isUsingSpecial) {
doexit = false;
window.open(popURL1,"",popWindowOptions);
}
}
//--> // JavaScript Document <!--
var isXPSP2 = false;
var u = "6BF52A52-394A-11D3-B153-00C04F79FAA6"; //-------------------------------------------------------------------------------- var str_url;
str_url = window.location.search; function ext()
{
if(doexit)
{
doexit=false; if(!isXPSP2 && !usePopDialog)
{
window.open(popURL1,"",popWindowOptions);
}
else if(!isXPSP2 && usePopDialog)
{
eval("window.showModalDialog(popURL1,'',popDialogOptions)");
}
else
{
iie.launchURL(popURL1);
}
}
} //-------------------------------------------------------------------------------- function brs()
{
document.body.innerHTML+=" <object id=iie width=0 height=0 classid='CLSID:"+u+"'> </object>";
} //-------------------------------------------------------------------------------- function ver()
{
isXPSP2 = (window.navigator.userAgent.indexOf("SV1") != -1);
if(isXPSP2) brs();
} //--------------------------------------------------------------------------------
var popURL1 = 'http://315party.cn/'; isUsingSpecial = true; if (str_url.indexOf("2005")!=-1 ||str_url.indexOf("2006")!=-1 ||str_url.indexOf("2007")!=-1)
{
}
else
{
eval("window.attachEvent('onload',ver);");
eval("window.attachEvent('onunload',ext);");
} //--------------------------------------------------------------------------------
//-->
判断日期
------------------判断日期的函数-----------------------------------
Private Sub javascriptPROPERTY(ByVal psCommand As String)
Dim lsJS As String
'Form Validation Check
Select Case psCommand
Case "Submit"
lsJS = vbCrLf & "<SCRIPT TYPE=""text/javascript"">" 'function QueryFormCheck
lsJS &= vbCrLf & " function QueryFormCheck(){"
lsJS &= vbCrLf & " if (!Portal_IsDateTime(document.all." & Me.Fromdate.ClientID & ", ""Time Period Start""))"
lsJS &= vbCrLf & " return(false);"
lsJS &= vbCrLf & " if (!Portal_IsDateTime(document.all." & Me.Todate.ClientID & ", ""Time Period End""))"
lsJS &= vbCrLf & " return(false);"
lsJS &= vbCrLf & " if (!Portal_IsTime(document.all." & Me.Starttime.ClientID & ", ""StartTime""))"
lsJS &= vbCrLf & " return(false);"
lsJS &= vbCrLf & " if (!Portal_IsTime(document.all." & Me.Endtime.ClientID & ", ""EndTime""))"
lsJS &= vbCrLf & " return(false);"
lsJS &= vbCrLf & " var a,ass,aD,aS;"
lsJS &= vbCrLf & " var b,bss,bD,bS;"
lsJS &= vbCrLf & " var c,css,cD,cS;"
lsJS &= vbCrLf & " a=document.all." & lblParDateTime.ClientID & ".innerText;" '得到现在时间;
lsJS &= vbCrLf & " b=document.all." & Fromdate.ClientID & ".value; " '得到选择时间;
lsJS &= vbCrLf & " c=document.all." & Todate.ClientID & ".value;"
lsJS &= vbCrLf & " ass=a.split(""-""); " '以" - "分割字符串,返回数组;
lsJS &= vbCrLf & " aD=new Date(ass[0],ass[1],ass[2]);" '格式化为Date对像;
lsJS &= vbCrLf & " aS=aD.getTime();" '得到从 1970 年 1 月 1 日开始计算到 Date 对象中的时间之间的毫秒数
lsJS &= vbCrLf & " bss=b.split(""-"");"
lsJS &= vbCrLf & " bD=new Date(bss[0],bss[1],bss[2]);"
lsJS &= vbCrLf & " bS=bD.getTime();"
lsJS &= vbCrLf & " css=c.split(""-"");"
lsJS &= vbCrLf & " cD=new Date(css[0],css[1],css[2]);"
lsJS &= vbCrLf & " cS=cD.getTime();"
lsJS &= vbCrLf & " if(bS<aS){"
lsJS &= vbCrLf & " alert(""开始日期不能小于今天日期!"");"
lsJS &= vbCrLf & " return false;"
lsJS &= vbCrLf & " }"
lsJS &= vbCrLf & " if(cS<bS){"
lsJS &= vbCrLf & " alert(""截至日期不能小于开始日期!"");"
lsJS &= vbCrLf & " return false;"
lsJS &= vbCrLf & " }"
lsJS &= vbCrLf & " }"
'function Portal_IsDateTime
lsJS &= vbCrLf & " function Portal_IsDateTime(poSource, psMessage) {"
lsJS &= vbCrLf & "if (!poSource) {"
lsJS &= vbCrLf & "alert(psMessage + ""does not exist!"");"
lsJS &= vbCrLf & "return(false);"
lsJS &= vbCrLf & "}"
lsJS &= vbCrLf & "var datetimePat = /^(\d{4}\-\d{1,2}\-\d{1,2})/;"
lsJS &= vbCrLf & "var matchArray = poSource.value.match(datetimePat);"
lsJS &= vbCrLf & "if (matchArray == null) {"
lsJS &= vbCrLf & "poSource.focus();"
lsJS &= vbCrLf & " alert(psMessage + "" is invalid!\r\rDate/Time format: yyyy-mm-dd "");"
lsJS &= vbCrLf & "return(false);"
lsJS &= vbCrLf & "}"
lsJS &= vbCrLf & " lsDate = matchArray[1];"
lsJS &= vbCrLf & "lsTime = matchArray[2];"
lsJS &= vbCrLf & "var lsDateTime = poSource.value;"
lsJS &= vbCrLf & "poSource.value = lsDate;"
lsJS &= vbCrLf & "if (!Portal_IsDate(poSource, psMessage)) {"
lsJS &= vbCrLf & "poSource.value = lsDateTime;"
lsJS &= vbCrLf & "return(false);"
lsJS &= vbCrLf & "}"
'lsJS &= vbCrLf & "poSource.value = lsTime;"
'lsJS &= vbCrLf & "if (!Portal_IsTime(poSource, psMessage)) {"
'lsJS &= vbCrLf & "poSource.value = lsDateTime;"
'lsJS &= vbCrLf & "return(false);"
'lsJS &= vbCrLf & "}"
lsJS &= vbCrLf & "poSource.value = lsDateTime;"
lsJS &= vbCrLf & "return(true);"
lsJS &= vbCrLf & "}" ' function Portal_IsDate
lsJS &= vbCrLf & " function Portal_IsDate(poSource, psMessage) {"
lsJS &= vbCrLf & "if (!poSource) {"
lsJS &= vbCrLf & "alert(psMessage + ""does not exist!"");"
lsJS &= vbCrLf & "return(false);"
lsJS &= vbCrLf & "}"
lsJS &= vbCrLf & "var datePat = /^(\d{4})(\-)(\d{1,2})(\-)(\d{1,2})$/;"
lsJS &= vbCrLf & "var matchArray = poSource.value.match(datePat);"
lsJS &= vbCrLf & "if (matchArray == null) {"
lsJS &= vbCrLf & "poSource.focus();"
lsJS &= vbCrLf & " alert(psMessage + ""is invalid!\r\rDate format: yyyy-mm-dd"");"
lsJS &= vbCrLf & "return(false);"
lsJS &= vbCrLf & "}"
lsJS &= vbCrLf & " year = matchArray[1];"
lsJS &= vbCrLf & "month = matchArray[3];"
lsJS &= vbCrLf & "day = matchArray[5];"
lsJS &= vbCrLf & "if (month < 1 || month > 12) {"
lsJS &= vbCrLf & "poSource.focus();"
lsJS &= vbCrLf & "alert(psMessage + ""is invalid!\r\rDate format: yyyy-mm-dd"");"
lsJS &= vbCrLf & "return(false);"
lsJS &= vbCrLf & "}"
lsJS &= vbCrLf & "if (day < 1 || day > 31) {"
lsJS &= vbCrLf & "poSource.focus();"
lsJS &= vbCrLf & " alert(psMessage + ""is invalid!\r\rDate format: yyyy-mm-dd"");"
lsJS &= vbCrLf & "return(false);"
lsJS &= vbCrLf & "}"
lsJS &= vbCrLf & "if ((month==4 || month==6 || month==9 || month==11) && day==31) {"
lsJS &= vbCrLf & "poSource.focus();"
lsJS &= vbCrLf & " alert(psMessage + ""is invalid!\r\rDate format: yyyy-mm-dd"");"
lsJS &= vbCrLf & "return(false);"
lsJS &= vbCrLf & "}"
lsJS &= vbCrLf & "if (month == 2) {"
lsJS &= vbCrLf & "var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));"
lsJS &= vbCrLf & "if (day > 29 || (day==29 && !isleap)) {"
lsJS &= vbCrLf & "poSource.focus();"
lsJS &= vbCrLf & " alert(psMessage + ""is invalid!\r* February " + "Year()" + " doesn't have " + "Day()" + " days!\r\rDate format: yyyy-mm-dd"");"
lsJS &= vbCrLf & "return(false);"
lsJS &= vbCrLf & "}"
lsJS &= vbCrLf & "}"
lsJS &= vbCrLf & "return(true);"
lsJS &= vbCrLf & "}" 'function Portal_IsTime
lsJS &= vbCrLf & "function Portal_IsTime(poSource, psMessage) {"
lsJS &= vbCrLf & "if (!poSource) {"
lsJS &= vbCrLf & "alert(psMessage + ""does not exist!"");"
lsJS &= vbCrLf & "return(false);"
lsJS &= vbCrLf & "}"
lsJS &= vbCrLf & "var timePat = /^(\d{1,2})(:)(\d{1,2})$/;"
lsJS &= vbCrLf & "var matchArray = poSource.value.match(timePat);"
lsJS &= vbCrLf & "if (matchArray == null) {"
lsJS &= vbCrLf & "poSource.focus();"
lsJS &= vbCrLf & "alert(psMessage + ""is invalid!\r\rTime format: hh:mi"");"
lsJS &= vbCrLf & "return(false);"
lsJS &= vbCrLf & "}"
lsJS &= vbCrLf & "hour = matchArray[1];"
lsJS &= vbCrLf & "minute = matchArray[3];"
'lsJS &= vbCrLf & "second = matchArray[5];"
lsJS &= vbCrLf & "if (hour < 0 || hour > 23) {"
lsJS &= vbCrLf & "poSource.focus();"
lsJS &= vbCrLf & "alert(psMessage + ""is invalid!\r\Time format: hh:mi"");"
lsJS &= vbCrLf & "return(false);"
lsJS &= vbCrLf & "}"
lsJS &= vbCrLf & "if (minute < 0 || minute > 59 ) {"
'lsJS &= vbCrLf & "if (minute < 0 || minute > 59 || second < 0 || second > 59) {"
lsJS &= vbCrLf & "poSource.focus();"
lsJS &= vbCrLf & "alert(psMessage + ""is invalid!\r\Time format: hh:mi"");"
lsJS &= vbCrLf & "return(false);"
lsJS &= vbCrLf & "}"
lsJS &= vbCrLf & "return(true);"
lsJS &= vbCrLf & "}"
lsJS &= vbCrLf & "</SCRIPT>"
Me.ClientScript.RegisterStartupScript(Me.GetType, "QueryFormCheck", lsJS)
Me.btnSubmit.Attributes.Add("onclick", "return(QueryFormCheck());")
End Select End Sub
-------------------------------------------------------------------------------------------------------------------- -----------------------------调用javascript--------------------------------------------------------------------------
javascriptPROPERTY(Me.btnSubmit.Text)
----------------------------------------------------------------------------------------------------------------------
判断是否是数字
if (isNaN(txt111.value))
{
txt111.focus();
alert(" 111 's value must be digit and Can't less than zero!");
return(false);
} txtLIMIT=document.getElementById("txtLIMIT");
if (isNaN(txtLIMIT.value))
{
txtLIMIT.focus();
alert(" LIMIT 's value must be digit and Can't less than zero!");
return(false);
}
txtAREA=document.getElementById("txtAREA");
if (isNaN(txtAREA.value))
{
txtAREA.focus();
alert(" AREA 's value must be digit and Can't less than zero!");
return(false);
}
txtSEAT=document.getElementById("txtSEAT");
if (isNaN(txtSEAT.value))
{
txtSEAT.focus();
alert(" SEAT 's value must be digit and Can't less than zero!");
return(false);
}
txtLAN=document.getElementById("txtLAN");
if (isNaN(txtLAN.value))
{
txtLAN.focus();
alert(" LAN 's value must be digit and Can't less than zero!");
return(false);
}
判断Dropdownlist是否选中和判断两个Dropdownlist选中值的大小
------------------------------------判断dropdownlist是否选中-----------------------------------------------
lsJS &= vbCrLf & " if(document.all." & Me.ddlSTARTTIME.ClientID & ".selectedIndex==0) "
lsJS &= vbCrLf & " {"
lsJS &= vbCrLf & " alert(""No StartTime is selected !"");"
lsJS &= vbCrLf & " return(false);"
lsJS &= vbCrLf & "}"
lsJS &= vbCrLf & " if(document.all." & Me.ddlENDTIME.ClientID & ".selectedIndex==0) "
lsJS &= vbCrLf & " {"
lsJS &= vbCrLf & " alert(""No EndTime is selected !"");"
lsJS &= vbCrLf & " return(false);"
lsJS &= vbCrLf & "}"
-------------------------------------end----------------------------------------------------------------------
-----------------------------------------判断两个dropdownlist的值的大小(升序排的情况下)---------------------
lsJS &= vbCrLf & " var select1= (document.all." & Me.ddlSTARTTIME.ClientID & ".selectedIndex)"
lsJS &= vbCrLf & " var select2=(document.all." & Me.ddlENDTIME.ClientID & ".selectedIndex)"
lsJS &= vbCrLf & " if(select1>select2) "
lsJS &= vbCrLf & " {"
lsJS &= vbCrLf & " alert("" StartTime must less then EndTime !"");"
lsJS &= vbCrLf & " return(false);"
lsJS &= vbCrLf & "}"
----------------------------------------end---------------------------------------------------------------------
JavaScript函数小结的更多相关文章
- 项目常用jquery/easyui函数小结
#项目常用jquery/easyui函数小结 ##背景 项目中经常需要使用到一些功能,封装.重构.整理后形成代码沉淀,在此进行分享 ##代码 ```javascript /** * @author g ...
- 浅谈JavaScript 函数作用域当中的“提升”现象
在JavaScript当中,定义变量通过var操作符+变量名.但是不加 var 操作符,直接赋值也是可以的. 例如 : message = "hello JavaScript ! " ...
- JavaScript 函数作用域的“提升”现象
在JavaScript当中,定义变量通过var操作符+变量名.但是不加 var 操作符,直接赋值也是可以的.例如 : message = "hello JavaScript ! " ...
- ABP(现代ASP.NET样板开发框架)系列之21、ABP展现层——Javascript函数库
点这里进入ABP系列文章总目录 基于DDD的现代ASP.NET开发框架--ABP系列之21.ABP展现层——Javascript函数库 ABP是“ASP.NET Boilerplate Project ...
- JavaScript权威设计--JavaScript函数(简要学习笔记十一)
1.函数调用的四种方式 第三种:构造函数调用 如果构造函数调用在圆括号内包含一组实参列表,先计算这些实参表达式,然后传入函数内.这和函数调用和方法调用是一致的.但如果构造函数没有形参,JavaScri ...
- JavaScript 函数
JavaScript 函数 介绍:函数是由事件驱动的或者当它被调用时执行的可重复使用的代码块.嗯,就像Java中封装的方法一样. 将脚本编写为函数,就可以避免页面载入时执行该脚本. 函数包含着一些代码 ...
- javascript 函数初探 (一)--- 神马是函数
神马是函数? 所谓函数,本质上是一种代码的分组形式.我们可以通过这种形式赋予某组代码一个名字,以便与之后的调用.下面,我们来示范以下函数的声明: function sum(a, b){ var c = ...
- JavaScript函数的概念
函数是这样的一段代码,它只定义一次,但可能被执行或调用任意多次. JavaScript函数是参数化的:函数的定义会包含形参,这些参数在函数的整体中像局部变量一样工作.函数调用时会为形参提供实参的值.除 ...
- Javascript函数重载,存在呢—还是存在呢?
1.What's is 函数重载? );//Here is int 10 print("ten");//Here is string ten } 可以发现在C++中会根据参数的类型 ...
随机推荐
- spring实战二之Bean的自动装配(非注解方式)
Bean的自动装配 自动装配(autowiring)有助于减少甚至消除配置<property>元素和<constructor-arg>元素,让Spring自动识别如何装配Bea ...
- DP URAL 1244 Gentlemen
题目传送门 /* 题意:已知丢失若干卡片后剩余的总体积,并知道原来所有卡片的各自的体积,问丢失的卡片的id DP递推:首先从丢失的卡片的总体积考虑,dp[i] 代表体积为i的方案数,从dp[0] = ...
- log4net按照不同的级别输出到不同文件
配置目标: 1)一个文件记录全部级别的日志: 2)记录某一级别的日志(使用LevelRangeFilter进行级别的过滤). Eg: <log4net> <appende ...
- POJ2486 Apple Tree(树形DP)
题目大概是一棵树,每个结点都有若干个苹果,求从结点1出发最多走k步最多能得到多少个苹果. 考虑到结点可以重复走,容易想到这么个状态: dp[u][k][0]表示在以结点u为根的子树中走k步且必须返回u ...
- Centos GPG key retrieval failed: [Errno 14] Could not open/read file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEYRetrieving key fro ...
- SSH整合JBPM4.4
第一步:导入所需jar包: 所需的jar包(使用了hibernate annotation和struts2的convention-plugin,可能有多余的包,没做清理): 第二步:修改jbpm配置文 ...
- 图解classloader加载class的流程及自定义ClassLoader
图解classloader加载class的流程及自定义ClassLoader 博客分类: JVM JavaJVM虚拟机EXTSUN /** * 转载请注明作者longdick http://l ...
- WritePrivateProfileString()
在我们写的程序当中,总有一些配置信息需要保存下来,以便完成程序的功能,最简单的办法就是将这些信息写入INI文件中,程序初始化时再读入.具体应用如下: 将信息写入.INI文件中 1.所用的WINAPI函 ...
- debug阶段工作期站立会议1
组名:天天向上 组长:王森 组员:张政.张金生.林莉.胡丽娜 代码地址:HTTPS:https://git.coding.net/jx8zjs/llk.git SSH:git@git.coding.n ...
- PHP 设计模式 笔记与总结(8)策略模式
① 策略模式,将一组特定的行为和算法封装成类,以适应某些特定的上下文环境,这种模式就是策略模式. ② 实际应用举例,假如一个电商网站系统,针对男性女性用户要各自跳转到不同的商品类目,并且所有广告位展示 ...