有什么方法可以从网站上获取智能手机号码吗? [英] Is there ANY way to get a Smart Phone number from website?
问题描述
我正在寻找一种使用HTML 5,Javascript或类似名称获取设备电话号码的方法.最近,我想获取设备的坐标.我可以通过用HTML 5编写类似的代码来轻松做到这一点:
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:
<!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.
推荐答案
没有不提示用户就无法使用JavaScript获取电话号码的可靠方法.也就是说,无法使用浏览器API自动检索它.
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.
可能在某些Android/iPhone应用程序视图内.查看此处的讨论:如何获取通过Android中的JavaScript获得设备的电话号码?.在这里:通过SDK获取本地iPhone号码
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
如评论中所述,这通常不是一件好事(隐私等).如果需要电话号码,一定会提示用户输入.
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.
这篇关于有什么方法可以从网站上获取智能手机号码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!