此代码适用于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>
任何提示?
答案 0 :(得分:1)
试试这个:
$(document).ready(function(){
$.get("http://api.hostip.info/get_html.php", function(data){
alert("Data Loaded: " + data);
});
})
答案 1 :(得分: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>