[英]I am developing a website in which i want to read some json file locally in my js file
[英]Is there a way to detect iPadOS/iPad device in a website that I am developing?
我想知道的是:有没有办法使用 HTML、CSS 或 JS 来检测特定设备(iPad)? 如果网站在 iPad 上被收购,我希望能够禁用一些代码。 到目前为止,我还不知道要禁用什么代码,因为我还不知道是什么导致了问题,但我正在通过反复试验进行研究,看看我是否可以通过某些更改让该站点在 iPad 上运行.
问题:我设计了一个网站,它有一个使用 CSS 的多边形在其上移动的叠加层。 该站点使用 HTML5、Bootstrap 4、Parallax(我知道它在 iPad 上不起作用,没有变通办法,这不是问题)和 JS。 问题是当网站加载到 iPad 上时它会闪烁,我认为是 CSS 构成了索引页面上的动画,但无论我打开哪个页面,它仍然闪烁。 我不知道原因是什么。 web 地址是www.ace-of-he-arts.com 。 如果您在任何帮助之前看到过此内容,我们将不胜感激。
您可以通过navigator.platform
检查 IOS 或任何其他设备,如 android。 你可以在这里阅读更多 -
https://www.w3schools.com/jsref/prop_nav_platform.asp
目前(2019 年)iPadPro 与其他平台的区别在于 iPadPro 支持触控。因此您可以使用它进行说明。
以下是您可以使用的一些有用的方法。
function isIOS() {
var pl=navigator.platform.toString().toLowerCase();
if (pl.includes("IPad") || pl.includes("IPhone") || pl.includes("IPod")){
return true;
} else {
return navigator.maxTouchPoints &&
navigator.maxTouchPoints > 2 &&
/MacIntel/.test(navigator.platform);
}
}
function isIpadOS() {
return navigator.maxTouchPoints &&
navigator.maxTouchPoints > 2 &&
/MacIntel/.test(navigator.platform);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.