Is the a specific webkit feature I can detect to check if a user is using a webkit browser

不羁的心 提交于 2019-12-11 03:46:58

问题


I've used the code below if I need to detect Firefox:

var firefox = !(window.mozInnerScreenX == null);

I'm curious if there is something similar to detect webkit browsers without checking the user agent string. Like checking a specific feature only webkit browsers have?


回答1:


Go to the console in Chrome and type window.webkit - the autocompletion will show you a stack of properties that should be Webkit specific (e.g. webkitRequestAnimationFrame, webkitAudioContext, etc)




回答2:


From my experience the best practise is to use

window.webkitConvertPointFromNodeToPage

window.WebKitCSSMatrix

window.WebKitPoint

These are one of the oldest properties, which support was firstly introduced in safari 4.0 Chrome supports this since first version, opera has owned such property right after it's engine migration.

UPD: @hexalys found a better solution:

'WebkitAppearance' in document.documentElement.style

this one is supported even in safari 3.0



来源:https://stackoverflow.com/questions/10176659/is-the-a-specific-webkit-feature-i-can-detect-to-check-if-a-user-is-using-a-webk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!