Reputation: 19
I want to have a Web page and identify every visitor somehow. Maybe using their MAC address. Is it possible to get the MAC address of visitors in my web page? or is there any other way to get what I want?
I don't want to make a login form because I hate when web pages ask me to log or to create an account, It would be better if the page just identify the device used on each case.
Thank you.
Upvotes: -1
Views: 1031
Reputation: 202
Asking users for their MAC addresses would raise security concerns and I don't think JavaScript allows a webpage access to that information. Not sure if this would serve your purpose but you could fetch the geolocation if user allows necessary permissions and then create a unique hash. You can find a detailed guide here on MDN Web Docs
function geoFindMe() {
const status = document.querySelector('#status');
const mapLink = document.querySelector('#map-link');
mapLink.href = '';
mapLink.textContent = '';
function success(position) {
const latitude = position.coords.latitude;
const longitude = position.coords.longitude;
status.textContent = '';
mapLink.href = `https://www.openstreetmap.org/#map=18/${latitude}/${longitude}`;
mapLink.textContent = `Latitude: ${latitude} °, Longitude: ${longitude} °`;
}
function error() {
status.textContent = 'Unable to retrieve your location';
}
if(!navigator.geolocation) {
status.textContent = 'Geolocation is not supported by your browser';
} else {
status.textContent = 'Locating…';
navigator.geolocation.getCurrentPosition(success, error);
}
}
document.querySelector('#find-me').addEventListener('click', geoFindMe);
Upvotes: 1