What is IP Address?
-> An Internet Protocol address is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication. An IP address serves two main functions: host or network interface identification and location addressing.
<!DOCTYPE html>
<html>
<head>
<title>Getting Clients IP</title>
<style>
*{margin:0;}
html, body{width:100%; height:100%;}
p, h1 { color: green;}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>
<script>
/* Add "https://api.ipify.org?format=json" statement
this will communicate with the ipify servers in order to retrieve the IP address $.getJSON will
load JSON-encoded data from the server using a
GET HTTP request */
$.getJSON("https://api.ipify.org?format=json", function(data) {
// Setting text of element P with id gfg
$("#gfg").html(data.ip);
})
</script>
</head>
<body align="center">
<h1>Your IP Address is:</h1>
<p id="gfg"></p>
</body>
</html>

No comments:
Post a Comment