forked from jackieli123723/JavaScript.Utilities
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJsDemo.aspx
More file actions
70 lines (65 loc) · 2.51 KB
/
JsDemo.aspx
File metadata and controls
70 lines (65 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JsDemo.aspx.cs" Inherits="YanZhiwei.JavaScript.Utilities.JsDemo" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Js Demo</title>
<script src="jsUtils.js"></script>
<script type="text/javascript">
function getFriendlyStringDemo() {
var _time = '2011-10-12 09:14:12';
_time = jsUtils.datetime.parseDateTime(_time);
console.log("getFriendlyString:" + jsUtils.datetime.getFriendlyString(_time));
}
function getUrlParamterDemo() {
var _url = window.location.href;
var _value = jsUtils.url.get(_url, 'keyid');
alert(_value);
}
//关于 javascript 委托 示例
function delegate() {
var ClassA = function () {
var _color = "red";
return {
getColor: function () {
alert("Color: " + _color);
},
setColor: function (color) {
_color = color;
}
};
};
var a = new ClassA();
var d = jsUtils.delegate(a, a.setColor);
d("blue");
a.getColor();
}
function urlget() {
var url = "yUtilsTest.html?Name='测试'";
var value = jsUtils.url.get(url, 'Name');
alert(value);
}
function jsonSerializeTest() {
var person = new Object();
person.name = "yanzhiwei";
person.age = 20;
var _json = jsUtils.json.serialize(person);
alert(_json);
}
function addHoursTest() {
alert(jsUtils.datetime.addHours(new Date(), 2));
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" type="button" value="getFriendlyString" onclick="getFriendlyStringDemo()" /><br />
<input id="Button2" type="button" value="getUrl" onclick="getUrlParamterDemo()" /><br />
<input id="Button3" type="button" value="delegate" onclick="delegate()" /><br />>
<input id="Button5" type="button" value="is" onclick="isTest()" /><br />
<input id="Button7" type="button" value="JsonSerialize" onclick="jsonSerializeTest()" /><br />
<input id="Button10" type="button" value="addHoursTest" onclick="addHoursTest()" />
</div>
</form>
</body>
</html>