Nov 19, 2014

Get Client IP and Referrer Using JQuery

The following piece of code can be used to get Client IP 
And The Referrer

function myIP() {
    if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest();
    else xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  
    xmlhttp.open("GET"," http://api.hostip.info/get_html.php ",false);
    xmlhttp.send();
  
    hostipInfo = xmlhttp.responseText;
  
    $("#display").text(hostipInfo);

   var referrer = document.referrer;

     $("#displayReferrer ").text(referrer);
  
    return false;
}  

Copy Paste This Code Below And Simply Do What Ever Your Planning To Do With It

<!DOCTYPE html>
<html>
<head> 
<title>Client IP</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
myIP();
});
function myIP() {
    if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest();
    else xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  
    xmlhttp.open("GET"," http://api.hostip.info/get_html.php ",false);
    xmlhttp.send();
  
    hostipInfo = xmlhttp.responseText;
  

    $("#display").text(hostipInfo);

    var referrer = document.referrer;

     $("#displayReferrer ").text(referrer);
  
    return false;
}  

</script>
</head>
<body>

<p id="display"></p>
<br>
<p id="displayReferrer "></p>
</body>
</html>

No comments:

JWT Token Decode Using Jquery

When it come to authentication we use many mechanism. Ones the user authenticated we must keep these details somewhere safe. So we can share...