<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nameserver Lookup Tool</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<h1>Nameserver Lookup Tool</h1>
<input type="text" id="domainInput" placeholder="Enter domain (e.g., example.com)">
<button onclick="lookupNameserver()">Lookup</button>
<div id="result"></div>
</div>
<script src="script.js"></script>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Arial, sans-serif;
}
body {
background: linear-gradient(to right, #ff7e5f, #feb47b);
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
text-align: center;
}
.container {
background: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.2);
max-width: 400px;
width: 100%;
}
h1 {
margin-bottom: 15px;
color: #333;
}
input {
width: 80%;
padding: 10px;
border: 2px solid #ff7e5f;
border-radius: 5px;
margin-bottom: 10px;
}
button {
background: #ff7e5f;
color: #fff;
border: none;
padding: 10px 15px;
border-radius: 5px;
cursor: pointer;
transition: 0.3s;
}
button:hover {
background: #e65c4f;
}
#result {
margin-top: 15px;
text-align: left;
color: #333;
}
async function lookupNameserver() {
const domain = document.getElementById("domainInput").value.trim();
const resultDiv = document.getElementById("result");
if (domain === "") {
resultDiv.innerHTML = "<p style='color: red;'>Please enter a domain.</p>";
return;
}
resultDiv.innerHTML = "<p>Fetching nameservers...</p>";
try {
const response = await fetch(`https://api.host.io/nameservers/${domain}?token=YOUR_API_KEY`);
const data = await response.json();
if (data.nameservers && data.nameservers.length > 0) {
let output = "<h3>Nameservers:</h3><ul>";
data.nameservers.forEach(ns => {
output += `<li>${ns}</li>`;
});
output += "</ul>";
resultDiv.innerHTML = output;
} else {
resultDiv.innerHTML = "<p>No nameservers found.</p>";
}
} catch (error) {
resultDiv.innerHTML = `<p style='color: red;'>Error fetching data.</p>`;
}
}
