Tablet mode: scrollbar width is 0 in Edge.
Not tablet mode: scrollbar width is not zero in Edge.
Working pure JavaScript code here.
This works for Edge (IE12) on Windows 10, but not Internet Explorer 11.
A reliable way to detect that the tablet mode has changed is here.
Note that scrollbar width can be zero for other reasons (iOS, Android, Windows Phone, Safari OSX, or if -ms-overflow-style: none
, amongst other reasons). Modernizr 3 has a hiddenscrollbar feature detection which detects if zero width scrollbars used.
Note that Edge scrollbars act and display differently if you are using touch, rather than using a mouse/touchpad. (You can even get both thin and old-school styles of scrollbar showing at once if you scroll then change into tablet mode quickly)! Beware that I suspected the Edge debugger of interfering with scrollbar detection (but it probably due to me changing between touch and touchpad).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…