Javascript unable to get hotspot lan IP address on mobile browser?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















i am trying to get both ip for client Remote and Lan IP address , for now i am able to do this on all platforms , but if user is connected on Mobile hotspot i am unable to verify his local lan ip , is it possible to get user local ip address while he is connected on mobile hotspot ?



its only happening on mobile browsers ..



My Code .



<html>
<head>
<meta charset='utf-8' />
<title>Get Local IP address</title>
<script>
const rtcpip=function( server, callback ) window.mozRTCPeerConnection ;

const create=function(t, a, p)
try
var el = ( typeof( t )=='undefined' catch( err )
console.warn( err.message );

;

const ipcallback=function( ip )
try
let type=false;

let ipv4=ip.split('.');
let ipv6=ip.split(':');

if( ipv4.length==4 )

if( ipv6.length > 1 )
switch( ipv6[0] )
case 'FE80':type='Link-Local';break;
case 'FEC0':type='site-local';break;
case '3FFE':type='global';break;
case '2002':type='global 6to4';break;
default:type='IPV6';break;

create( null, innerHTML:ip + ' ' + type , document.getElementById( 'ip' ) );
/*
you can use this callback to pass the ip address information on to a php script
or do something more interesting
*/

catch( err )
console.info( err.message )




rtcpip.call( this, 'google1', ipcallback );
</script>
<style>
bodydisplay:flex;flex-direction:column;justify-content:center;align-items:center;height:100vh;width:100%;padding:0;margin:0;font-family:calibri,verdana,arial;font-size:1rem;
#ipdisplay:flex;align-items:center;justify-content:center;flex-direction:column;width:50%;min-height:5rem;height:auto;box-sizing:border-box;border:2px dashed rgba(133,133,133,0.25);border-radius:1rem;color:rgba(133,133,133,0.95);box-shadow: 0 10px 25px rgba(133,133,133,0.95);text-align:center;margin:0 auto;float:none;background:whitesmoke
</style>
</head>
<body>
<div id='ip'></div>
</body>
</html>


Try it here










share|improve this question

















  • 1





    I run your page on an Android phone that is connected to a mobile hotspot and it displayed the local IP address. Then I connected to my home router and refreshed the page, local IP stayed the same but public IP updated. I opened a new tab and visited your page, then the IP is updated. I think the problem is not getting the private IP address, it only works when the page is loaded the first time.

    – mk_
    Nov 24 '18 at 19:37











  • @mk_ Thanks for the feedback , i didn't test it on Android i tested it on iOS , i think the issue with iOS platforms

    – Jack
    Nov 26 '18 at 7:24

















0















i am trying to get both ip for client Remote and Lan IP address , for now i am able to do this on all platforms , but if user is connected on Mobile hotspot i am unable to verify his local lan ip , is it possible to get user local ip address while he is connected on mobile hotspot ?



its only happening on mobile browsers ..



My Code .



<html>
<head>
<meta charset='utf-8' />
<title>Get Local IP address</title>
<script>
const rtcpip=function( server, callback ) window.mozRTCPeerConnection ;

const create=function(t, a, p)
try
var el = ( typeof( t )=='undefined' catch( err )
console.warn( err.message );

;

const ipcallback=function( ip )
try
let type=false;

let ipv4=ip.split('.');
let ipv6=ip.split(':');

if( ipv4.length==4 )

if( ipv6.length > 1 )
switch( ipv6[0] )
case 'FE80':type='Link-Local';break;
case 'FEC0':type='site-local';break;
case '3FFE':type='global';break;
case '2002':type='global 6to4';break;
default:type='IPV6';break;

create( null, innerHTML:ip + ' ' + type , document.getElementById( 'ip' ) );
/*
you can use this callback to pass the ip address information on to a php script
or do something more interesting
*/

catch( err )
console.info( err.message )




rtcpip.call( this, 'google1', ipcallback );
</script>
<style>
bodydisplay:flex;flex-direction:column;justify-content:center;align-items:center;height:100vh;width:100%;padding:0;margin:0;font-family:calibri,verdana,arial;font-size:1rem;
#ipdisplay:flex;align-items:center;justify-content:center;flex-direction:column;width:50%;min-height:5rem;height:auto;box-sizing:border-box;border:2px dashed rgba(133,133,133,0.25);border-radius:1rem;color:rgba(133,133,133,0.95);box-shadow: 0 10px 25px rgba(133,133,133,0.95);text-align:center;margin:0 auto;float:none;background:whitesmoke
</style>
</head>
<body>
<div id='ip'></div>
</body>
</html>


Try it here










share|improve this question

















  • 1





    I run your page on an Android phone that is connected to a mobile hotspot and it displayed the local IP address. Then I connected to my home router and refreshed the page, local IP stayed the same but public IP updated. I opened a new tab and visited your page, then the IP is updated. I think the problem is not getting the private IP address, it only works when the page is loaded the first time.

    – mk_
    Nov 24 '18 at 19:37











  • @mk_ Thanks for the feedback , i didn't test it on Android i tested it on iOS , i think the issue with iOS platforms

    – Jack
    Nov 26 '18 at 7:24













0












0








0


2






i am trying to get both ip for client Remote and Lan IP address , for now i am able to do this on all platforms , but if user is connected on Mobile hotspot i am unable to verify his local lan ip , is it possible to get user local ip address while he is connected on mobile hotspot ?



its only happening on mobile browsers ..



My Code .



<html>
<head>
<meta charset='utf-8' />
<title>Get Local IP address</title>
<script>
const rtcpip=function( server, callback ) window.mozRTCPeerConnection ;

const create=function(t, a, p)
try
var el = ( typeof( t )=='undefined' catch( err )
console.warn( err.message );

;

const ipcallback=function( ip )
try
let type=false;

let ipv4=ip.split('.');
let ipv6=ip.split(':');

if( ipv4.length==4 )

if( ipv6.length > 1 )
switch( ipv6[0] )
case 'FE80':type='Link-Local';break;
case 'FEC0':type='site-local';break;
case '3FFE':type='global';break;
case '2002':type='global 6to4';break;
default:type='IPV6';break;

create( null, innerHTML:ip + ' ' + type , document.getElementById( 'ip' ) );
/*
you can use this callback to pass the ip address information on to a php script
or do something more interesting
*/

catch( err )
console.info( err.message )




rtcpip.call( this, 'google1', ipcallback );
</script>
<style>
bodydisplay:flex;flex-direction:column;justify-content:center;align-items:center;height:100vh;width:100%;padding:0;margin:0;font-family:calibri,verdana,arial;font-size:1rem;
#ipdisplay:flex;align-items:center;justify-content:center;flex-direction:column;width:50%;min-height:5rem;height:auto;box-sizing:border-box;border:2px dashed rgba(133,133,133,0.25);border-radius:1rem;color:rgba(133,133,133,0.95);box-shadow: 0 10px 25px rgba(133,133,133,0.95);text-align:center;margin:0 auto;float:none;background:whitesmoke
</style>
</head>
<body>
<div id='ip'></div>
</body>
</html>


Try it here










share|improve this question














i am trying to get both ip for client Remote and Lan IP address , for now i am able to do this on all platforms , but if user is connected on Mobile hotspot i am unable to verify his local lan ip , is it possible to get user local ip address while he is connected on mobile hotspot ?



its only happening on mobile browsers ..



My Code .



<html>
<head>
<meta charset='utf-8' />
<title>Get Local IP address</title>
<script>
const rtcpip=function( server, callback ) window.mozRTCPeerConnection ;

const create=function(t, a, p)
try
var el = ( typeof( t )=='undefined' catch( err )
console.warn( err.message );

;

const ipcallback=function( ip )
try
let type=false;

let ipv4=ip.split('.');
let ipv6=ip.split(':');

if( ipv4.length==4 )

if( ipv6.length > 1 )
switch( ipv6[0] )
case 'FE80':type='Link-Local';break;
case 'FEC0':type='site-local';break;
case '3FFE':type='global';break;
case '2002':type='global 6to4';break;
default:type='IPV6';break;

create( null, innerHTML:ip + ' ' + type , document.getElementById( 'ip' ) );
/*
you can use this callback to pass the ip address information on to a php script
or do something more interesting
*/

catch( err )
console.info( err.message )




rtcpip.call( this, 'google1', ipcallback );
</script>
<style>
bodydisplay:flex;flex-direction:column;justify-content:center;align-items:center;height:100vh;width:100%;padding:0;margin:0;font-family:calibri,verdana,arial;font-size:1rem;
#ipdisplay:flex;align-items:center;justify-content:center;flex-direction:column;width:50%;min-height:5rem;height:auto;box-sizing:border-box;border:2px dashed rgba(133,133,133,0.25);border-radius:1rem;color:rgba(133,133,133,0.95);box-shadow: 0 10px 25px rgba(133,133,133,0.95);text-align:center;margin:0 auto;float:none;background:whitesmoke
</style>
</head>
<body>
<div id='ip'></div>
</body>
</html>


Try it here







javascript android ios networking hotspot






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 9:02









JackJack

10k72360




10k72360







  • 1





    I run your page on an Android phone that is connected to a mobile hotspot and it displayed the local IP address. Then I connected to my home router and refreshed the page, local IP stayed the same but public IP updated. I opened a new tab and visited your page, then the IP is updated. I think the problem is not getting the private IP address, it only works when the page is loaded the first time.

    – mk_
    Nov 24 '18 at 19:37











  • @mk_ Thanks for the feedback , i didn't test it on Android i tested it on iOS , i think the issue with iOS platforms

    – Jack
    Nov 26 '18 at 7:24












  • 1





    I run your page on an Android phone that is connected to a mobile hotspot and it displayed the local IP address. Then I connected to my home router and refreshed the page, local IP stayed the same but public IP updated. I opened a new tab and visited your page, then the IP is updated. I think the problem is not getting the private IP address, it only works when the page is loaded the first time.

    – mk_
    Nov 24 '18 at 19:37











  • @mk_ Thanks for the feedback , i didn't test it on Android i tested it on iOS , i think the issue with iOS platforms

    – Jack
    Nov 26 '18 at 7:24







1




1





I run your page on an Android phone that is connected to a mobile hotspot and it displayed the local IP address. Then I connected to my home router and refreshed the page, local IP stayed the same but public IP updated. I opened a new tab and visited your page, then the IP is updated. I think the problem is not getting the private IP address, it only works when the page is loaded the first time.

– mk_
Nov 24 '18 at 19:37





I run your page on an Android phone that is connected to a mobile hotspot and it displayed the local IP address. Then I connected to my home router and refreshed the page, local IP stayed the same but public IP updated. I opened a new tab and visited your page, then the IP is updated. I think the problem is not getting the private IP address, it only works when the page is loaded the first time.

– mk_
Nov 24 '18 at 19:37













@mk_ Thanks for the feedback , i didn't test it on Android i tested it on iOS , i think the issue with iOS platforms

– Jack
Nov 26 '18 at 7:24





@mk_ Thanks for the feedback , i didn't test it on Android i tested it on iOS , i think the issue with iOS platforms

– Jack
Nov 26 '18 at 7:24












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53315733%2fjavascript-unable-to-get-hotspot-lan-ip-address-on-mobile-browser%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53315733%2fjavascript-unable-to-get-hotspot-lan-ip-address-on-mobile-browser%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo