JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 11th, 2006, 07:17 AM
Nirbhayanand Nirbhayanand is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 1 Nirbhayanand User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 41 sec
Reputation Power: 0
Question Dns lookup using javascript

Any one can tell me if it is possible to get IP address of a particular site using its name ie-www.rediffmail.com and it will return IP address on client side in javascript.

Reply With Quote
  #2  
Old October 11th, 2006, 08:11 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 14
I do'nt think it's possible using Javascript alone.
You might be best using a server side script for that.

Out of curiousity, why would you need to do that?
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter!
DevArticles Forum Moderator

"The net is a waste of time, and that's exactly what's right about it." -- William Gibson

Reply With Quote
  #3  
Old October 11th, 2006, 04:34 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - *Local Friend*
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 469 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 36 m 37 sec
Reputation Power: 9
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
you could you javascript but it may not be the real ip, you could use...

var ip = '<!--#echo var="REMOTE_ADDR"-->';

hope this helped

colton22
Comments on this post
Icon disagrees: I do not think this code does a DNS lookup..

Reply With Quote
  #4  
Old October 12th, 2006, 01:14 AM
Icon's Avatar
Icon Icon is offline
Command Line Warrior
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Sep 2005
Posts: 1,021 Icon User rank is Private First Class (20 - 50 Reputation Level)Icon User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Weeks 7 h 49 m 32 sec
Reputation Power: 11
I guess that would mean breaking out of the sandbox, so it should not be possible. You could go for a server-side script in combination with an ajax call (like MCD said).
__________________
There is no such thing as C/C++, you either program C or C++

Reply With Quote
  #5  
Old October 13th, 2006, 08:03 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - *Local Friend*
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 469 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 36 m 37 sec
Reputation Power: 9
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
there is a way to do it in a java applet, but oveously this involves java which some people dont have enabled, i found it on a site when i searched for ip address look up, i couldnt find the code though, only the working model.

colton22

ps i dont know how the code would go, but i do know how i would access the page that contains it.

Reply With Quote
  #6  
Old October 17th, 2006, 12:14 PM
Nilpo's Avatar
Nilpo Nilpo is offline
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Location: New Springfield, OH
Posts: 154 Nilpo User rank is Private First Class (20 - 50 Reputation Level)Nilpo User rank is Private First Class (20 - 50 Reputation Level)  Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 18 h 1 m 47 sec
Reputation Power: 9
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
There are a couple of websites that provide DNS lookup services. I'm not sure if any of them support Java calls though. Perhaps in conjunction with a hidden form, but now you're talking about workarounds.

Reply With Quote
  #7  
Old June 2nd, 2007, 04:01 PM
CINodras CINodras is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Location: Eureka, CA
Posts: 1 CINodras User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 16 sec
Reputation Power: 0
Post Some Example Code...

Here are some simple example scripts that will lookup a domain name submitted via an HTML form, using a server sided PHP script.

Name the files as suggested in the comments, and place all three of them in the same directory.

Code:
<html>
<!--
FILENAME: dnslookup.html
This file's name isn't important, however.
-->
<head>
<title>DNS Check</title>
<script language="javascript" src="dnscheck.js"></script>
</head>
<body>
    <table width="0%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td align="right">DOMAIN:</td>
            <td align="left"><input type="text" id="domainTxt" name="domainTxt"></td>
            <td align="left"><span id="output" class="inputFormError"></span></td>
          </tr>
          <tr>
            <td align="center" colspan="2"><input type="submit" id="submitBtn" value="Submit" onclick="dnsCheck('domainTxt','output')"></td>
          </tr>
    </table>
</body>
</html>


Code:
//Javascript DNS Lookup
//FILENAME: dnscheck.js
//06-02-2007
//Eli Moulton

var serverData = false;

if (window.XMLHttpRequest)
{
	serverData = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
	serverData = new ActiveXObject("Microsoft.XMLHTTP");
}

function dnsCheck(inputId,outputId)
{
	var outputElem = document.getElementById(outputId);
	var inputElem  = document.getElementById(inputId);
	var lookupResults;
	if (serverData)
	{
		serverData.open('GET','dnscheck.php?domain=' + inputElem.value);
		serverData.onreadystatechange = function()
		{
			if (serverData.readyState == 4 && serverData.status == 200)
			{
				lookupResults = serverData.responseText;
				if (lookupResults == -150)
				{
					outputElem.innerHTML = "No Domain Given";
				}
				else if (lookupResults == -100)
				{
					outputElem.innerHTML = "Lookup Failed/Invalid Domain";
				}
				else
				{
					outputElem.innerHTML = "IP: " + lookupResults;
				}
			}
		}
		serverData.send(null);
	}
	else
	{
		outputElem.innerHTML = "Failed To Create XMLHttpRequest Object";
	}
}


Code:
<?php
//DNSCheck server script for use with dnscheck.js
//FILENAME: dnscheck.php
//06-02-2007
//Eli Moulton

if ($_GET['domain'])
{
	$lookupData = dns_get_record($_GET['domain'],DNS_A);
	if ($lookupData)
	{
		echo $lookupData[0]['ip'];
	}
	else
		echo -100;
}
else
{
	echo -150;
}
?>


I hope you find this helpful.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Dns lookup using javascript


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap