javascript 有没有办法从网站上获取智能手机号码?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21270536/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 20:31:49  来源:igfitidea点击:

Is there ANY way to get a Smart Phone number from website?

javascriptandroidhtml

提问by SamyCode

I'm searching for a way to get the phone number of a device using HTML 5, Javascript or something like it. Recently, I wanted to get the coordinates of the device. I could easily do that by writing something in HTML 5 like:

我正在寻找一种使用 HTML 5、Javascript 或类似方法获取设备电话号码的方法。最近想获取设备的坐标。我可以通过在 HTML 5 中编写一些内容来轻松做到这一点,例如:

<!DOCTYPE html>
<html>
<body>
<p id="demo">Click the button to get your coordinates:</p>
<button onclick="getLocation()">Try It</button>
<script>
var x=document.getElementById("demo");
function getLocation()
  {
  if (navigator.geolocation)
    {
    navigator.geolocation.getCurrentPosition(showPosition);
    }
  else{x.innerHTML="Geolocation is not supported by this browser.";}
  }
function showPosition(position)
  {
  x.innerHTML="Latitude: " + position.coords.latitude + 
  "<br>Longitude: " + position.coords.longitude;    
  }
</script>
</body>
</html>

Now I'm almost done with my part of the job, but the last thing I need to do is to get the phone number of the smartphone that access that website.

现在我几乎完成了我的部分工作,但我需要做的最后一件事是获取访问该网站的智能手机的电话号码。

Is there ANY way to do this? :/ please... and thank you.

有没有办法做到这一点?:/ 谢谢,麻烦您了。

回答by ebuat3989

There is no reliable way to get a phone number with JavaScript without prompting the user. That is, it cannot be retrieved automatically using a browser API.

没有可靠的方法可以在不提示用户的情况下使用 JavaScript 获取电话号码。也就是说,它不能使用浏览器 API 自动检索。

It is possible inside of certain Android / iPhone application views. See discussions here: How can I get the device's phone number through JavaScript in Android?. And here: Getting the local iPhone number through SDK

在某些 Android / iPhone 应用程序视图中是​​可能的。请参阅此处的讨论:如何在 Android 中通过 JavaScript 获取设备的电话号码?. 在这里:通过 SDK 获取本地 iPhone 号码

As mentioned in comments, this is not a good thing to do in general (privacy, etc.). Definitely prompt the user for input if the phone number is needed.

正如评论中提到的,这通常不是一件好事(隐私等)。如果需要电话号码,肯定会提示用户输入。

回答by pickman

i think it is possible. the network providers at my country(kenya)- www.safaricom.com.do seam to some how get your mobile phone number when you open there website. even when using a modem you can buy data online without having to input your number cause you get it already printed out. i tried using wi-fi tethering from my android phone en then opened there site en they could still get my mobile phone number. try reading the source code of the site maybe it might help. maybe it has to do with much more than basic js and php. i tried changing the number using the developer tools but it doesn,t work.

我认为这是可能的。我的国家(肯尼亚)的网络供应商- www.safaricom.com .做一些如何在打开那里的网站时获取您的手机号码的方法。即使使用调制解调器,您也可以在线购买数据,而无需输入您的号码,因为您已将其打印出来。我尝试从我的 android 手机使用 Wi-Fi 网络共享,然后打开那里的网站,他们仍然可以获得我的手机号码。尝试阅读该网站的源代码,也许会有所帮助。也许它不仅仅与基本的 js 和 php 有关。我尝试使用开发人员工具更改号码,但它不起作用。