请问怎么通过javascript读当前的操作系统是98、winme还是2000、xp?

crinoid 2003-10-27 05:26:24
同上
谢谢!
...全文
53 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Kanderliu 2003-10-27
  • 打赏
  • 举报
回复
说明浏览器请在<body>与</body>之间加入:
<script language="JavaScript" >
<!--
window.document.write(navigator.appName)
//-->
</script>
<script language="JavaScript" >
<!--
window.document.write(parseInt(navigator.appVersion))
//-->
</script>
zhfkiller 2003-10-27
  • 打赏
  • 举报
回复
<HTML xmlns:IE>
<HEAD>
<STYLE>
@media all {
IE\:CLIENTCAPS {behavior:url(#default#clientCaps)}
}
</STYLE>

<SCRIPT>
function window.onload()
{
sTempStr = "availHeight = " + oClientCaps.availHeight + "\n" +
"availWidth = " + oClientCaps.availWidth + "\n" +
"bufferDepth = " + oClientCaps.bufferDepth + "\n" +
"colorDepth = " + oClientCaps.colorDepth + "\n" +
"connectionType = " + oClientCaps.connectionType + "\n" +
"cookieEnabled = " + oClientCaps.cookieEnabled + "\n" +
"cpuClass = " + oClientCaps.cpuClass + "\n" +
"height = " + oClientCaps.height + "\n" +
"javaEnabled = " + oClientCaps.javaEnabled + "\n" +
"platform = " + oClientCaps.platform + "\n" +
"systemLanguage = " + oClientCaps.systemLanguage + "\n" +
"userLanguage = " + oClientCaps.userLanguage + "\n" +
"width = " + oClientCaps.width + "\n" ;

oPre.innerText = sTempStr;
}
</SCRIPT>

</HEAD>
<BODY>
<H1>clientCaps Behavior Sample</H1>

<P>This example shows how to use the new <B>clientCaps</B>
behavior, introduced in Microsoft Internet Explorer 5, to obtain
client capabilities information. The following is a sampling of the
information that can be obtained:</P>

<IE:CLIENTCAPS ID="oClientCaps" />

<PRE id="oPre"></PRE>
</BODY>
</HTML>
kingdomzhf 2003-10-27
  • 打赏
  • 举报
回复
应该是这个
userAgent Property

--------------------------------------------------------------------------------

Retrieves a string equivalent to the HTTP user-agent request header.

Syntax

HTML N/A
Scripting [ sUserAgent = ] object.userAgent

Possible Values

sUserAgent String爐hat specifies a valid HTTP user agent.

The property is read-only. The property has no default value.

Expressions can be used in place of the preceding value(s), as of Microsoft?Internet Explorer 5. For more information, see Dynamic Properties.

Remarks

The HTTP user-agent request header contains information about compatibility, the browser, and the platform name. For more information about the browser, see the appName property. For more information about the platform, see the appVersion property.

The userAgent property dynamically returns a different value depending on the browser and platform versions. For example, Microsoft?Internet Explorer 4.01 returns the following string for Microsoft ?Windows?95.

Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)

Example

This example uses the userAgent property to specify a required platform before additional script is executed. For example, if Windows 95 is a requirement for the document, you can use a variable to determine whether the user is running the necessary operating system. The "bIs95" variable is set to true if Windows 95 is found in the userAgent value and the additional script is processed.

<SCRIPT>
var bIs95=false;
window.onload=fnInit;
function fnInit(){
if(navigator.userAgent.indexOf("Windows 95")>-1){
bIs95=true;
}
if(bIs95==true){
// Process additional script.
}
}
</SCRIPT>
Kanderliu 2003-10-27
  • 打赏
  • 举报
回复
说明操作系统请在<body>与</body>之间加入:
<script language="JavaScript" >
agent = navigator.userAgent; if (agent.lastIndexOf("Win95")) { document.write(' Windows 95/NT'); } else if (agent.lastIndexOf("Win16")) { document.write(' Windows 3.1'); } else if (agent.lastIndexOf("Mac")) { document.write(' Macintosh'); } else if (agent.lastIndexOf("Unix")) { document.write(' Unix'); } else if (agent.lastIndexOf("Linux")) { document.write(' Linux'); }
</script>
zhfkiller 2003-10-27
  • 打赏
  • 举报
回复
kingdomzhf 2003-10-27
  • 打赏
  • 举报
回复
window.clientInformation.platform



platform Property

--------------------------------------------------------------------------------

Retrieves the name of the user's operating system.

Syntax

HTML N/A
Scripting [ sPlatform = ] object.platform

Possible Values

sPlatform String that receives one of the following values:HP-UX HP Unix-based machines.
MacPPC Macintosh PowerPC-based machines.
Mac68K Macintosh 68K-based machines.
SunOS Solaris-based machines.
Win32 Microsoft?Windows?32-bit platform.
Win16 Windows 16-bit platform.
WinCE Windows CE platform.


The property is read-only. The property has no default value.

longshenwang 2003-10-27
  • 打赏
  • 举报
回复
我也想知道 帮你顶 ...

87,987

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧