문제

I've recently discovered that you can use this to detect Windows versions:

<!--[if WindowsEdition]>Blah<![endif]-->

But what values does WindowsEdition use?

Basically I'm trying to use a conditional comment to detect if users of Internet Explorer are on a Windows version that would support an upgrade to IE9 or above. I'd like to be able to detect the difference between "Windows XP and below" and "Windows Vista and higher".

The purpose of this is to direct users of IE7 and below to either an update to IE9/10, or a switch to Chrome/Firefox if their OS doesn't support IE9. The reason for doing this is that the site works in IE8, but lacks many CSS features so it is, in a few words, "ugly but usable".

도움이 되었습니까?

해결책

Only versions of Windows Vista or newer will return a value to the WindowEdition conditional comment.

From the Conditional Comment Wikipedia page

An integer corresponding to the edition of Windows used to view the Web page. Returns a Boolean value of true if the value matches the edition being used. For information about supported values and the editions they describe, see the pdwReturnedProductType parameter of the GetProductInfo function.

emphasis is mine. By edition they mean Home, Home Starter, Professional, Ultimate, etc.

The MSDN page for the GetProductInfo function supports this. The page also lists the input parameters for GetProductInfo which include

dwOSMajorVersion [in]

The major version number of the operating system. The minimum value is 6.

Version 6 corresponds to Vista, so I suspect Windows XP and versions of Windows older than XP do not have this GetProductInfo function, cannot call it and won't return anything to compare to the conditional comment in IE.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top