-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils-urlParser.html
93 lines (86 loc) · 2.58 KB
/
Utils-urlParser.html
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pattaya.Global.Utils</title>
<link rel="stylesheet" href="css/base.css" />
<link href="css/demo.css" type="text/css" rel="stylesheet"/>
<script type="text/javascript" src="js/jquery-1.7.js"></script>
<script type="text/javascript" src="js/global.js"></script>
</head>
<body>
<article class="layout">
<hgroup class="header">
<h1>Pattaya.Global.Utils.urlParser</h1>
<h4>定义操作url的一系列方法:</h4>
</hgroup>
<ol>
<li class="cbox">
<h3 class="title">urlParser(url)</h3>
<div class="container">
<h4 class="subtitle">概述:</h4>
<div class="subcon">
分析url, 并返回一些列快速操作url的方法。
</div>
<h4 class="subtitle">参数:</h4>
<ul class="subcon">
<li>
<b>url:</b>
<span>可以是绝对路径, 也可以是相对路径(相对当前页面的url)。</span>
</li>
</ul>
<h4 class="subtitle">返回值介绍:</h4>
<ul class="subcon">
<li>
<b>get(string param)</b>
<span>根据参数,返回相应的url字段值</span>
</li>
<li>
<b>set(string param, string value)</b>
<span>设置某一url字段的值</span>
</li>
<li>
<b>getParam(string param)</b>
<span>获取某一url的search字段的参数值</span>
</li>
<li>
<b>setParam(string param, string value)</b>
<span>设置某一url的search字段的参数值</span>
</li>
</ul>
<h4 class="subtitle">Example:</h4>
<div class="subcon example">
<pre>
var oUrl = Pattaya.Global.Utils.urlParser("../a.html?a=1#asd");
oUrl.get("href");
oUrl.get("protocol");
oUrl.get("hostname");
oUrl.get("port");
oUrl.get("host");
oUrl.get("search");
oUrl.setParam('a', 122);
oUrl.getParam('a'); //122
</pre>
</div>
</div>
<script>
var oUrl = Pattaya.Global.Utils.urlParser("http://www.baidu.com/Utils.html?cccc=1#aaaa");
var url = window.location;
console.log(oUrl.get("href"));
console.log(oUrl.get("protocol"));
console.log(oUrl.get("hostname"));
console.log(oUrl.get("port"));
console.log(oUrl.get("host"));
console.log(oUrl.get("pagename"));
console.log(oUrl.get("pathname"));
console.log(oUrl.get("search"));
console.log(oUrl.get("hash"));
console.log(oUrl.getParam('a'));
oUrl.setParam('a', 122);
console.log(oUrl.get("href"));
</script>
</li>
</ol>
</article>
</body>
</html>