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
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.
also I think that is possible, in my country (in Italy) when I go on site of iliad they know my phone number, I also tried it in incognito mode
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.
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.