you can use Ajax. for example//javascript
var xml_get_ip;
var get_ip=function(){
if(window.XMLHttpRequest){
xml_get_ip=new XMLHttpRequest();
}else if(typeof ActiveXObject != "undefined"){
xml_get_ip=new ActiveXObject("Microsoft.XMLHTTP");
}xml_get_ip.open("POST","get_id.php",true);xml_get_ip.onreadystatechange=_get_state;xml_get_ip.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xml_get_ip.send(null);}var _get_state=function(){if(xml_get_ip.readyState==4){//show the response content, the responseText is all of the content you should use.
alert(xml_get_ip.responseText);
}
}//I think you should know that how to deal the responseText.// if you still have problems, send mail to me: [email protected]

解决方案 »

  1.   

    //this row is to open the page get_id.php which I named your code above.
    xml_get_ip.open("POST","get_id.php",true);
      

  2.   

    you can do it like this.you want get the IP from another page?<!-- page example.htm -->
    <html>
    //javascript
    var xml_get_ip;
    var get_ip=function(){
    if(window.XMLHttpRequest){
    xml_get_ip=new XMLHttpRequest();
    }else if(typeof ActiveXObject != "undefined"){
    xml_get_ip=new ActiveXObject("Microsoft.XMLHTTP");
    }xml_get_ip.open("POST","get_id.php",true);xml_get_ip.onreadystatechange=_get_state;xml_get_ip.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xml_get_ip.send(null);}var _get_state=function(){if(xml_get_ip.readyState==4){//show the response content, the responseText is all of the content you should use.
    alert(xml_get_ip.responseText);
    }
    }
    <script>
    </script><body onload="get_ip()">
    <!-- .......-->
    </body>
    </html>
      

  3.   

    <!-- page example.htm -->
    <html>
    <script>
    //javascript
    var xml_get_ip;
    var get_ip=function(){
    if(window.XMLHttpRequest){
    xml_get_ip=new XMLHttpRequest();
    }else if(typeof ActiveXObject != "undefined"){
    xml_get_ip=new ActiveXObject("Microsoft.XMLHTTP");
    }xml_get_ip.open("POST","get_id.php",true);xml_get_ip.onreadystatechange=_get_state;xml_get_ip.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xml_get_ip.send(null);}var _get_state=function(){if(xml_get_ip.readyState==4){//show the response content, the responseText is all of the content you should use.
    alert(xml_get_ip.responseText);
    }
    }
    </script><body onload="get_ip()">
    <!-- .......-->
    </body>
    </html>
    <?php
    //get_ip.php
    include_once('./images/ip/slogin.php');
    $QQWry=new QQWry;
    function get_real_ip(){
     //............
    }get_real_ip();
    ?>at this page's end, you should execute this function(), and here I remand you that you can't call a php function directly by using javascript.if you still have problems, send mail to me: [email protected]