Can I perform a DNS lookup (hostname to IP address) using client-side Javascript?

Edit: This question gave me an itch, so I put up a JSONP webservice on Google App Engine that returns the clients ip address. Usage: <script type=”application/javascript”> function getip(json){ alert(json.ip); // alerts the ip address } </script> <script type=”application/javascript” src=”http://jsonip.appspot.com/?callback=getip”> </script> Yay, no server proxies needed. Pure JS can’t. If you have a server script … Read more

How do browser cookie domains work?

Although there is the RFC 2965 (Set-Cookie2, had already obsoleted RFC 2109) that should define the cookie nowadays, most browsers don’t fully support that but just comply to the original specification by Netscape. There is a distinction between the Domain attribute value and the effective domain: the former is taken from the Set-Cookie header field … Read more

Regular expression to match DNS hostname or IP Address?

You can use the following regular expressions separately or by combining them in a joint OR expression. ValidIpAddressRegex = “^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$”; ValidHostnameRegex = “^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$”; ValidIpAddressRegex matches valid IP addresses and ValidHostnameRegex valid host names. Depending on the language you use \ could have to be escaped with \. ValidHostnameRegex is valid as per RFC 1123. Originally, … Read more