-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
113 lines (109 loc) · 3.97 KB
/
index.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE html>
<html>
<head>
<title>urlParams</title>
<script src="urlParams.js"></script>
<style>
.res {
font-style: italic;
color: #b3b3b3;
}
</style>
<!-- Intercom -->
<script>
window.intercomSettings = {
app_id: "yvqft4t9"
};
</script>
<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/yvqft4t9';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>
</head>
<body>
<h1>URLparams</h1>
<p>urlParams can be easily referenced through the urlParams.parameter syntax.</p>
<div id="eg1"></div>
<p>Of course, you can also use urlParams['parameter']</p>
<div id='eg2'></div>
<p>All you need to do is place this code in the head of your HTML, and you can reference urlParams in all your scripts</p>
<code id="cp"><script src="https://booligoosh.github.io/urlParams/urlParams.js"></script></code>
<script>
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
if (!Object.keys) {
Object.keys = (function() {
'use strict';
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString'),
dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
],
dontEnumsLength = dontEnums.length;
return function(obj) {
if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
throw new TypeError('Object.keys called on non-object');
}
var result = [], prop, i;
for (prop in obj) {
if (hasOwnProperty.call(obj, prop)) {
result.push(prop);
}
}
if (hasDontEnumBug) {
for (i = 0; i < dontEnumsLength; i++) {
if (hasOwnProperty.call(obj, dontEnums[i])) {
result.push(dontEnums[i]);
}
}
}
return result;
};
}());
}
var values = [];
var keys = Object.keys(urlParams);
for (var i = 0; i < keys.length; i++) {
values.push(urlParams[keys[i]]);
}
for (var i = 0; i < keys.length; i++) {
var t1 = 'urlParams.' + keys[i];
var t2 = '=> ' + values[i];
var e = document.createElement("code");
var node = document.createTextNode(t1);
e.appendChild(node);
var p = document.getElementById("eg1");
p.appendChild(e);
var b = document.createElement("br");
p.appendChild(b);
var e = document.createElement("code");
var node = document.createTextNode(t2);
e.appendChild(node);
e.className = 'res'
var p = document.getElementById("eg1");
p.appendChild(e);
var b = document.createElement("br");
p.appendChild(b);
//EG2
var t1 = 'urlParams["' + keys[i]+ '"]';
var e = document.createElement("code");
var node = document.createTextNode(t1);
e.appendChild(node);
var p = document.getElementById("eg2");
p.appendChild(e);
var b = document.createElement("br");
p.appendChild(b);
var e = document.createElement("code");
var node = document.createTextNode(t2);
e.appendChild(node);
e.className = 'res'
var p = document.getElementById("eg2");
p.appendChild(e);
var b = document.createElement("br");
p.appendChild(b);
}
</script>
</body>
</html>