Created
July 6, 2024 16:06
-
-
Save bhaireshm/45eeb36ba544da07335e4315037beacb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Local IP Address</title> | |
</head> | |
<style> | |
.ip { | |
font-size: large; | |
text-align: center; | |
padding: 10px; | |
border: 3px solid grey; | |
border-radius: 5px; | |
border-style: dashed; | |
} | |
</style> | |
<body> | |
<div style="padding: 50px;margin: 50px auto;"> | |
<h1 id="ip">Checking...</h1> | |
</div> | |
</body> | |
<script type="application/javascript"> | |
function getIP(json) { | |
document.querySelector("#ip").textContent = json.ip; | |
} | |
</script> | |
<script type="application/javascript" src="https://api.ipify.org?format=jsonp&callback=getIP"></script> | |
<!-- <script> | |
var xhttp = new XMLHttpRequest(); | |
xhttp.onreadystatechange = function () { | |
if (this.readyState == 4 && this.status == 200) { | |
document.querySelector("#ip").textContent = xhttp.responseText; | |
} | |
}; | |
xhttp.open("GET", "https://api.ipify.org", true); | |
xhttp.send(); | |
</script> --> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment