0

此代码适用于 Chrome 和 Firefox,但不适用于 IE8 ><

 <script src="jquery-latest.js"></script>

 <script type="text/javascript">

    $.get("http://api.hostip.info/get_html.php", function(data){
        alert("Data Loaded: " + data);

    });
 </script>

有小费吗?

4

2 回答 2

1

尝试这个:

$(document).ready(function(){
    $.get("http://api.hostip.info/get_html.php", function(data){
        alert("Data Loaded: " + data);   
    });
})
于 2012-08-23T08:42:59.307 回答
0

这是另一种方法,它实际上在 IE 中获取 IP:

<script type="text/javascript">
window.onload = function () {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = "http://jsonip.appspot.com/?callback=DisplayIP";
    document.getElementsByTagName("head")[0].appendChild(script);
};

function DisplayIP(response) {
    document.getElementById("ipaddress").innerHTML = "Your IP Address is " 
                                                      + response.ip;
}
</script>

<span id="ipaddress"></span>
于 2012-08-24T07:47:26.057 回答