You can use this function for this:
/**
* Determine the mobile operating system.
* This function either returns 'iOS', 'Android' or 'unknown'
*
* @returns {String}
*/
function getMobileOperatingSystem() {
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
if( userAgent.match( /iPad/i ) || userAgent.match( /iPhone/i ) || userAgent.match( /iPod/i ) )
{
return 'iOS';
}
else if( userAgent.match( /Android/i ) )
{
return 'Android';
}
else
{
return 'unknown';
}
}
You can see more options of how to do this here
I hope I’ve helped.
update
<script type="text/javascript">
//Aqui você esconde todos os botões.
$("#apple-store").hide();
$("#google-play").hide();
var dispositivo = navigator.userAgent.toLowerCase();
console.log(dispositivo);
if(dispositivo.search(/android/) > -1) {
//Se for android você mostra esse.
$("#google-play").show();
} else if(dispositivo.search(/iphone/) > -1) {
//Se for iphone você mostra esse.
$("#apple-store").show();
} else {
//e assim sucessivamente.
console.log('Outro device');
}
</script>
<button id="apple-store">Apple Store</button>
<button id="google-play">Google Play</button>
Actually this code that I passed the question is already bringing the correct device, now I need to show the image on the screen, I do not know how to show the image on the page, depending on the device.
– Edinho Rodrigues
You can do this in many ways I’ll put a simple way in the answer.
– Ricardo Mota