简体   繁体   English

有没有办法在我正在开发的网站中检测 iPadOS/iPad 设备?

[英]Is there a way to detect iPadOS/iPad device in a website that I am developing?

What I want to know: is there a way to detect a particular device (iPad) using either HTML, CSS or JS?我想知道的是:有没有办法使用 HTML、CSS 或 JS 来检测特定设备(iPad)? I want to be able to disable some code if the site is bought up on an iPad.如果网站在 iPad 上被收购,我希望能够禁用一些代码。 As of yet I don't know what code I want to disable because I don't yet know what is causing the problem but I am researching through trial and error to see if I can get the site to work on the iPad with certain changes.到目前为止,我还不知道要禁用什么代码,因为我还不知道是什么导致了问题,但我正在通过反复试验进行研究,看看我是否可以通过某些更改让该站点在 iPad 上运行.

The Issue: I designed a website that has an overlay that has polygons moving across it using CSS.问题:我设计了一个网站,它有一个使用 CSS 的多边形在其上移动的叠加层。 The site uses HTML5, Bootstrap 4, Parallax (I know it does not work on iPad without work arounds and it is not the problem) and JS.该站点使用 HTML5、Bootstrap 4、Parallax(我知道它在 iPad 上不起作用,没有变通办法,这不是问题)和 JS。 The problem is that when the site loads on an iPad it flickers, I thought it was the CSS that makes up the animations on the index page, but no matter which page I bring up it still flickers.问题是当网站加载到 iPad 上时它会闪烁,我认为是 CSS 构成了索引页面上的动画,但无论我打开哪个页面,它仍然闪烁。 I am at a lost as to what the cause is.我不知道原因是什么。 The web address is www.ace-of-he-arts.com . web 地址是www.ace-of-he-arts.com If you have seen this before any help would be appreciated.如果您在任何帮助之前看到过此内容,我们将不胜感激。

You can check for IOS or any other device like android by navigator.platform .您可以通过navigator.platform检查 IOS 或任何其他设备,如 android。 You can read more here -你可以在这里阅读更多 -

https://www.w3schools.com/jsref/prop_nav_platform.asp https://www.w3schools.com/jsref/prop_nav_platform.asp

Currently (2019) difference between iPadPro and the other platforms is that iPadPro is touch enabled.So you can use it for clarification.目前(2019 年)iPadPro 与其他平台的区别在于 iPadPro 支持触控。因此您可以使用它进行说明。

Here are a couple of helpful methods you can use.以下是您可以使用的一些有用的方法。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM