Create index.html
Browse files- index.html +55 -0
index.html
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<title>
|
| 5 |
+
How To Get URL Parameters using JavaScript?
|
| 6 |
+
</title>
|
| 7 |
+
<script src = "https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.0/FileSaver.min.js" integrity="sha512-csNcFYJniKjJxRWRV1R7fvnXrycHP6qDR21mgz1ZP55xY5d+aHLfo9/FcGDQLfn2IfngbAHd8LdfsagcCqgTcQ==" crossorigin = "anonymous" referrerpolicy = "no-referrer"> </script>
|
| 8 |
+
|
| 9 |
+
</head>
|
| 10 |
+
|
| 11 |
+
<body>
|
| 12 |
+
<h1 style="color:green;">
|
| 13 |
+
Omnibus
|
| 14 |
+
</h1> <b>
|
| 15 |
+
How To Get URL Parameters
|
| 16 |
+
With JavaScript?
|
| 17 |
+
</b>
|
| 18 |
+
<p> The url used is:
|
| 19 |
+
Current URL
|
| 20 |
+
</p>
|
| 21 |
+
|
| 22 |
+
<p>
|
| 23 |
+
Click on the button to get the url
|
| 24 |
+
parameters in the console.
|
| 25 |
+
<a href src="index2.html">go to index2</a>
|
| 26 |
+
</p>
|
| 27 |
+
|
| 28 |
+
<button onclick="getParameters()"> Get URL parameters </button>
|
| 29 |
+
|
| 30 |
+
<div id="output"></div>
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
<script>
|
| 36 |
+
function getParameters() {
|
| 37 |
+
let urlString = window.location.href;
|
| 38 |
+
let paramString = urlString.split('?')[1];
|
| 39 |
+
let params_arr = paramString.split('&');
|
| 40 |
+
for(let i = 0; i < params_arr.length; i++) {
|
| 41 |
+
let pair = params_arr[i].split('=');
|
| 42 |
+
document.getElementById('output').innerHTML = "<p>" + "Key is:" + pair[0] + "<br>" + "Value is:" + pair[1]+"</p>";
|
| 43 |
+
console.log("Key is:" + pair[0]);
|
| 44 |
+
console.log("Value is:" + pair[1]);
|
| 45 |
+
var blob = new Blob(["<p>" + "Key is:" + pair[0] + "<br>" + "Value is:" + pair[1]+"</p>"], {
|
| 46 |
+
type: "text/plain;charset=utf-8",
|
| 47 |
+
});
|
| 48 |
+
saveAs(blob, "download.txt");
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
getParameters()
|
| 52 |
+
|
| 53 |
+
</script>
|
| 54 |
+
</body>
|
| 55 |
+
</html>
|