-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.html
59 lines (48 loc) · 1.61 KB
/
node.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Page about node</title>
</head>
<body>
<h3>Page about node</h3>
<h2>with id = <span id="nodeId"></span></h2>
<script>
function getAllUrlParams(url) {
var queryString = url ? url.split('?')[1] : window.location.search.slice(1);
var obj = {};
if (queryString) {
queryString = queryString.split('#')[0];
var arr = queryString.split('&');
for (var i=0; i<arr.length; i++) {
var a = arr[i].split('=');
var paramNum = undefined;
var paramName = a[0].replace(/\[\d*\]/, function(v) {
paramNum = v.slice(1,-1);
return '';
});
var paramValue = typeof(a[1])==='undefined' ? true : a[1];
paramName = paramName.toLowerCase();
paramValue = paramValue.toLowerCase();
if (obj[paramName]) {
if (typeof obj[paramName] === 'string') {
obj[paramName] = [obj[paramName]];
}
if (typeof paramNum === 'undefined') {
obj[paramName].push(paramValue);
}
else {
obj[paramName][paramNum] = paramValue;
}
}
else {
obj[paramName] = paramValue;
}
}
}
return obj;
}
document.getElementById('nodeId').innerHTML = getAllUrlParams().id;
</script>
</body>
</html>