问题
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