Looking to create a unique webAPP with different content displays based on how it is accessed.
- If the user opens the webAPP through their Safari browser
- Or if they open the webAPP from a webclip on their home screen
The detection is functioning, as confirmed by document.write, but the CSS display property refuses to change. What could be causing this issue?
Appreciate any help in advance!
<html>
<head>
<meta name="apple-mobile-web-app-capable" content="yes">
<script type="text/javascript">
if (window.navigator.userAgent.indexOf('iPhone') != -1) {
if (window.navigator.standalone == true) {
// document.write('<p>homescreen<\/p>');
document.getElementById("homescreen").style.display = 'block';
}else{
// document.write('<p>safari<\/p>');
document.getElementById("safari").style.display = 'block';
}
}else{
// document.write('<p>no iOS<\/p>');
document.getElementById("ios").style.display = 'block';
}
</script>
</head>
<body>
<div id="homescreen" style="display:none;">
you opened it from the homescreen
</div>
<div id="safari" style="display:none;">
you opened it from safari
</div>
<div id="ios" style="display:none;">
you have no iOS
</div>
</body>
</html>