WHOIS Domain Lookup Tool

WHOIS Domain Lookup Tool

Not Available

'; let html = '
'; if (contact.name) html += `
Name: ${escapeHTML(contact.name)}
`; if (contact.organization) html += `
Organization: ${escapeHTML(contact.organization)}
`; if (contact.email) html += `
Email: ${escapeHTML(contact.email)}
`; if (contact.phone) html += `
Phone: ${escapeHTML(contact.phone)}
`; if (contact.city) html += `
Location: ${escapeHTML(contact.city)}, ${escapeHTML(contact.state)} ${escapeHTML(contact.postal_code)}, ${escapeHTML(contact.country)}
`; html += '
'; return html === '
' ? '

Not Available

' : html; } function escapeHTML(str) { if (!str) return ''; return str.replace(/[&<>"']/g, function(m) { return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[m]; }); } function showMessage(message, isError = true) { ui.errorMsg.textContent = message; ui.errorMsg.className = isError ? 'bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded-lg' : 'bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded-lg'; ui.errorMsg.style.display = 'block'; } // --- API CALL & RENDER --- async function fetchWhoisData(domain) { ui.loader.style.display = 'block'; ui.resultsContainer.style.display = 'none'; ui.errorMsg.style.display = 'none'; currentWhoisData = null; try { const response = await fetch(`https://whoisjson.com/api/v1/whois?domain=${encodeURIComponent(domain)}`); const data = await response.json(); if (data.error) { throw new Error(data.error); } currentWhoisData = data; renderResults(data); } catch (error) { console.error("WHOIS Fetch Error:", error); showMessage(`Error: ${error.message || 'Failed to fetch data. Please check the domain or try again.'}`); } finally { ui.loader.style.display = 'none'; } } function renderResults(data) { ui.domain.textContent = data.domain || 'N/A'; ui.registrar.textContent = data.registrar?.name || 'N/A'; ui.created.textContent = formatDate(data.created_date); ui.expires.textContent = formatDate(data.expires_date); ui.registrant.innerHTML = renderContact(data.registrant); ui.admin.innerHTML = renderContact(data.admin); ui.tech.innerHTML = renderContact(data.tech); ui.raw.textContent = data.raw_text || 'No raw data available.'; ui.resultsContainer.style.display = 'block'; } // --- PDF DOWNLOAD --- function downloadPDF() { if (!currentWhoisData) { alert("Please look up a domain before downloading."); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF(); const data = currentWhoisData; doc.setFontSize(18); doc.text(`WHOIS Report for: ${data.domain}`, 14, 22); doc.setFontSize(11); doc.setTextColor(100); doc.text(`Report Generated: ${new Date().toLocaleString('en-US')}`, 14, 28); let yPos = 40; doc.setFontSize(14); doc.setTextColor(0); doc.text("Summary", 14, yPos); doc.autoTable({ startY: yPos + 5, theme: 'grid', head: [['Parameter', 'Value']], body: [ ['Domain', data.domain], ['Registrar', data.registrar?.name || 'N/A'], ['Created On', formatDate(data.created_date)], ['Expires On', formatDate(data.expires_date)], ['Updated On', formatDate(data.updated_date)], ] }); yPos = doc.autoTable.previous.finalY + 10; function addContactSection(title, contact) { if (yPos > 250) { doc.addPage(); yPos = 20; } doc.setFontSize(14); doc.text(title, 14, yPos); let body = [['Not Available', '']]; if (contact) { body = [ ['Name', contact.name], ['Organization', contact.organization], ['Email', contact.email], ['Phone', contact.phone], ['Address', `${contact.city || ''} ${contact.state || ''} ${contact.postal_code || ''}`.trim()], ['Country', contact.country], ].filter(row => row[1]); // Filter out empty rows } doc.autoTable({ startY: yPos + 5, theme: 'striped', body: body, }); yPos = doc.autoTable.previous.finalY + 10; } addContactSection("Registrant Information", data.registrant); addContactSection("Admin Contact", data.admin); addContactSection("Tech Contact", data.tech); if (yPos > 250) { doc.addPage(); yPos = 20; } doc.setFontSize(14); doc.text("Raw WHOIS Text", 14, yPos); doc.setFontSize(8); doc.setTextColor(50); doc.text(doc.splitTextToSize(data.raw_text || 'N/A', 180), 14, yPos + 8); doc.save(`WHOIS_Report_${data.domain}.pdf`); } // --- EVENT LISTENERS --- ui.form.addEventListener('submit', function(e) { e.preventDefault(); const domain = ui.input.value.trim(); if (domain) { fetchWhoisData(domain); } }); ui.pdfBtn.addEventListener('click', downloadPDF); ui.accordions.forEach(item => { const header = item.querySelector('.whois-accordion-header'); header.addEventListener('click', () => { item.classList.toggle('active'); }); }); // --- NO TABS OR NAV BUTTONS NEEDED FOR THIS TOOL --- });
Scroll to Top