此代码适用于 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>
有小费吗?
此代码适用于 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>
有小费吗?
尝试这个:
$(document).ready(function(){
$.get("http://api.hostip.info/get_html.php", function(data){
alert("Data Loaded: " + data);
});
})
这是另一种方法,它实际上在 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>