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

后端 未结 16 1476
没有蜡笔的小新
没有蜡笔的小新 2020-11-22 11:45

I would like to use client-side Javascript to perform a DNS lookup (hostname to IP address) as seen from the client\'s computer. Is that possible?

16条回答
  •  盖世英雄少女心
    2020-11-22 11:52

    My version is like this:

    php on my server:

    
    

    jQuery on the page:

    var self = this;
    $.ajax({
        url: this.url + "getip.php",
        data: null,
        type: 'GET',
        crossDomain: true,
        dataType: 'jsonp'
    
    }).done( function( json ) {
    
        self.ip = json;
    
    });
    

    It works cross domain. It could use a status check. Working on that.

提交回复
热议问题