Untitled
unknown
html
2 years ago
2.8 kB
1
Indexable
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>IP Address Lookup</title> </head> <body> <h1>IP Address Lookup</h1> <button onclick="getData()">Get Data</button> <p>Your IP address is: <span id="ip-address"></span></p> <p>Browser type is: <span id="browser-type"></span></p> <p>Referring/exit pages: <span id="referring-exit-pages"></span></p> <p>Date/time stamps: <span id="date-time-stamps"></span></p> <p>Type of traffic generated: <span id="traffic-type"></span></p> <script> function getData() { const xhr = new XMLHttpRequest(); xhr.open('GET', 'https://api.ipify.org'); xhr.onload = function() { if (xhr.status === 200) { const ipAddress = xhr.responseText; document.getElementById('ip-address').textContent = ipAddress; } }; xhr.send(); const xhr2 = new XMLHttpRequest(); xhr2.open('GET', 'https://www.whatismybrowser.com/'); xhr2.onload = function() { if (xhr2.status === 200) { const browserData = JSON.parse(xhr2.responseText); document.getElementById('browser-type').textContent = browserData.user_agent.family; } }; xhr2.send(); const xhr3 = new XMLHttpRequest(); xhr3.open('GET', 'https://api.whatismyreferer.com/'); xhr3.onload = function() { if (xhr3.status === 200) { const referrerData = JSON.parse(xhr3.responseText); document.getElementById('referring-exit-pages').textContent = referrerData.referer; } }; xhr3.send(); const xhr4 = new XMLHttpRequest(); xhr4.open('GET', 'https://api.timezonedb.com/v2.1/get-time-zone'); xhr4.onload = function() { if (xhr4.status === 200) { const timeData = JSON.parse(xhr4.responseText); document.getElementById('date-time-stamps').textContent = timeData.formatted; } }; xhr4.send(); const xhr5 = new XMLHttpRequest(); xhr5.open('GET', 'https://api.trafficsource.org/'); xhr5.onload = function() { if (xhr5.status === 200) { const trafficData = JSON.parse(xhr5.responseText); document.getElementById('traffic-type').textContent = trafficData.source; } }; xhr5.send(); } </script> </body> </html>