forked from srikanthnaidu65/full-stack-java
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJS_Assignment3.html
More file actions
35 lines (32 loc) · 808 Bytes
/
JS_Assignment3.html
File metadata and controls
35 lines (32 loc) · 808 Bytes
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
<!DOCTYPE html>
<html>
<head>
<title>JS - Assignment 3</title>
</head>
<body>
<h3>
Parsing URL: <span id="url"></span>
</h3>
Protocol:
<span id="protocol"></span>
<br> Host:
<span id="host"></span>
<br> Port:
<span id="port"></span>
<br> Path:
<span id="path"></span>
<br> Query String:
<span id="query"></span>
<br>
<script>
var link = "http://localhost:8080/search?name=srikanth";
var url = new URL(link);
document.getElementById("url").innerHTML = link;
document.getElementById("protocol").innerHTML = url.protocol;
document.getElementById("port").innerHTML = url.port;
document.getElementById("host").innerHTML = url.hostname;
document.getElementById("path").innerHTML = url.pathname;
document.getElementById("query").innerHTML = url.search;
</script>
</body>
</html>