문제

Possible Duplicate:
Can I lookup the IP address of a hostname from javascript?

Hi is there a jquery eqivalent to the php gethostbyname() function?

도움이 되었습니까?

해결책

No, but you could make an ajax call to your server. The php on the server would then find it for you and return an answer. Note the following is untested.

Jquery

$.getJSON('gethostbyname.php', function(data){
    alert('Php said: ' +  data.ip);
});

-- EDIT --

Php

<?php
    $ip = gethostbyname('www.foo.com');
    $data.ip = $ip;
?>

If you wan't the domain to be dynamic you will have to use JQuery ajax

다른 팁

Try the hostname property of the location object in your JavaScript:

window.location.hostname
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top