Ive written the HTML below to allow the clients browser to lookup whois (the aim was to send reply back to the host). This works while testing offline but due to security you cant load a page from a remote site using XMLHttpRequest. Do you know how this could be done?
Im wanting the client browser to lookup whois then return the data back to a server. This will help keep whois data upto date also help get around the 1000 lookup a day limit.
Im wanting the client browser to lookup whois then return the data back to a server. This will help keep whois data upto date also help get around the 1000 lookup a day limit.
Code:
<head>
<script language="JavaScript">
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp=false;
}
}
if (!xmlhttp && window.createRequest) {
try {
xmlhttp = window.createRequest();
} catch (e) {
xmlhttp=false;
}
}
function FetchPage(domain,ref) {
xmlhttp.open("GET", "http://webwhois.nic.uk/cgi-bin/whois.cgi?query="+domain,true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
if (xmlhttp.responseText.indexOf('This domain name has not been registered') !=-1)
{
document.getElementById('domain'+ref).innerHTML='Domain '+domain+' <b>available</b>'
document.getElementById('domain'+ref).style.display='block'
}
else
{
var wdate = xmlhttp.responseText.substr(xmlhttp.responseText.indexOf('lookup made at ')+13);
var wdate = wdate.substr(2,wdate.indexOf('--')-8);
document.getElementById('hide'+ref).style.display='block'
document.getElementById('domain'+ref).innerHTML=' '+domain+' <b>Not available</b>'+wdate
document.getElementById('domain'+ref).style.display='block'
document.getElementById('expand'+ref).style.display='none'
document.getElementById('whois'+ref).innerHTML=xmlhttp.responseText
document.getElementById('whois'+ref).style.display='block'
}
}
}
xmlhttp.send(null)
}
function rez(ref) {
document.getElementById('domain'+ref).style.display='none'
document.getElementById('expand'+ref).style.display='block'
document.getElementById('hide'+ref).style.display='none'
document.getElementById('whois'+ref).style.display='none'
}
</script>
<title>test</title>
</head>
<body>
<div id='hide99' style="display:none">[<a href="#" onClick="rez(99);return false;">-</a>]</div>
<div id='domain99' style="display:none"></div>
<div id='expand99' style="display:block">[<a href="#" onClick="FetchPage('somesite.co.uk',99);return false;">+</a>] somesite.co.uk</div>
<div id='whois99' style="display:none"></div>
<div id='hide98' style="display:none">[<a href="#" onClick="rez(98);return false;">-</a>]</div>
<div id='domain98' style="display:none"></div>
<div id='expand98' style="display:block">[<a href="#" onClick="FetchPage('whatdomain.co.uk',98);return false;">+</a>] whatdomain.co.uk</div>
<div id='whois98' style="display:none"></div>
</body>
</html>