What causes

The front-end time just finished the iPad compatibility problem, I thought it would be OK, but then there was a customer feedback bug.

After careful consideration, the reason may be that the judgment of iPad is invalid. I asked the customer that the iPad system is version 13.2.2 and I am waiting for upgrade for a long time….

After updating to 13.2.3, I printed the iPad navigator.userAgent string and found that the familiar/iPad word was missing!!

The printed data is as follows,

"Mozilla / 5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Safari/605.1.15"

OMG, exactly the same as Safari on PC.

The new version of iPad was released last month without notice!! It is estimated that there will be a large number of front-end developers encountered unknown bugs, the collective circle 😂

The solution

After a long period of obscurating, I took a closer look at the differences between Safari Navigator on the PC and iPad. Still, I noticed a slight difference

Navigator. maxTouchpoints returns the maximum number of simultaneous touches that the current device can support

The value of print navigator. maxTouchpoints on iPad is 5

The value of print navigator. maxTouchpoints on a PC is 0

In a PC environment, switch to Mobile mode (Toggle Device Toolbar) and print navigator. maxTouchpoints with a value of 1

So to judge the iPad, here’s how I modified it

The export function isIPad () {/ / compatible with the 13.2 x version return/the /. The test (the navigator. UserAgent) | | (/Mac/.test(navigator.userAgent) && navigator.maxTouchPoints > 0) }

The customer is waiting, can only solve so first, you still have what more orthodox formal method, do not stingy comment.