怎么写判断是IE还是NETSCAPE的代码?

csdnchen 2001-05-12 10:38:00
...全文
42 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
BrentIvan 2001-05-12
  • 打赏
  • 举报
回复
<html>

<head>
<title>版本监测程序</title>
<link rel="stylesheet" href="../style.css">
</head>

<body>
<table width="740" align="left">
<tr>
<td align="center">
<font color="darkgreen"><big><big><big><b>系统侦测</b></big></big></big><br>
---能检测到许多操作系统,包括LINUX,Mac,UNIX等,还能侦测您是否支持ActiveX---</font>
</td>
</tr>
<tr><td align="center">

<hr color="#448844" size="1">

<form NAME="form">
<p>
<object ID="Label1" WIDTH="96" HEIGHT="24" CLASSID="CLSID:978C9E23-D4B0-11CE-BF2D-00AA003F40D0">
<param name="Caption" value="ActiveX">
</object>
</p>
<div align="left"><p>你的系统侦测结果是:<br>
<script LANGUAGE="JavaScript">
<!-- // Hide Script from old browsersvar
/* OS checking in appVersion by Norman G. King
Email: cable@i1.net http://www.i1.net/~cable
*/
function mac(){
return(navigator.appVersion.lastIndexOf('Mac') != -1 );
}
/* Netscape reports the processor type, Internet Explorer doesn't */
function ppc(){
return(navigator.appVersion.lastIndexOf('PPC') != -1 );
}
function intel(){
return((navigator.appVersion.lastIndexOf('Intel') != -1) || (navigator.appVersion.lastIndexOf('x86') != -1));
}
function mot(){
return((navigator.appVersion.lastIndexOf('68000') != -1) || (navigator.appVersion.lastIndexOf('68K') != -1));
}
function rhapsody(){
return(navigator.appVersion.lastIndexOf('Rhapsody') != -1 );
}
function openstep(){ return(navigator.appVersion.lastIndexOf('OpenStep') != -1 );
}
function nextos(){
return(navigator.appVersion.lastIndexOf('Next') != -1 );
}
function linux(){
return(navigator.appVersion.lastIndexOf('Linux') != -1 );
}
function os2(){
return((navigator.appVersion.lastIndexOf('OS/2') != -1) || (navigator.appVersion.lastIndexOf('OS2') != -1));
}
function win(){
return(navigator.appVersion.lastIndexOf('Win') != -1 );
}
function win95(){
return((navigator.appVersion.lastIndexOf('Windows 95') != -1) || (navigator.appVersion.lastIndexOf('Win95') != -1));
}
function winNT(){
return((navigator.appVersion.lastIndexOf('Windows NT') != -1) || (navigator.appVersion.lastIndexOf('WinNT') != -1));
}
function irix(){
return(navigator.appVersion.lastIndexOf('IRIX') != -1 );
}
function aix(){
return(navigator.appVersion.lastIndexOf('AIX') != -1 );
}
function sunos(){
return(navigator.appVersion.lastIndexOf('SUNOS') != -1 );
}
function solaris(){
return(navigator.appVersion.lastIndexOf('Solaris') != -1 );
}
function amiga(){
return(navigator.appVersion.lastIndexOf('Amiga') != -1);
}
function netscape(){
return(navigator.appName.lastIndexOf('Netscape') != -1 );
}
function explorer(){
return(navigator.appName.lastIndexOf('Explorer') != -1 );
}



// -->
</script> <script LANGUAGE="JavaScript">
<!-- // Hide Script from old browsers
/* Gets browser's name and version by Norman G. King
Email: cable@i1.net http://www.i1.net/~cable
*/

function getBrowserNameVersion()
{ return(navigator.appName + " " + navigator.appVersion); }
// -->
</script> <script LANGUAGE="JavaScript">
<!-- Beginning of JavaScript Applet -------------------
/* Finds out the browser name and version and the OS used
and if ActiveX is enabled. By Norman G. King
Email: cable@i1.net http://www.i1.net/~cable
*/

document.write(getBrowserNameVersion() + "<BR>");
if (netscape()) document.write("You are using Netscape<br>");
if (explorer()) document.write("You are using Internet Explorer<br>");
if (win95()) document.write("You are using Windows 95<br>");
if (winNT()) document.write("You are using Windows NT<br>");
if (mac()) document.write("You are using a Macintosh<br>");
if (linux()) document.write("You are using Linux<br>");
if (nextos()) document.write("You are using NeXTStep<br>");
if (os2()) document.write("You are using OS/2<br>");
if (rhapsody()) document.write("You are using Rhapsody<br>");
if (openstep()) document.write("You are using OpenStep<br>");
if (irix()) document.write("You are using IRIX<br>");
if (sunos()) document.write("You are using SunOS<br>");
if (aix()) document.write("You are using AIX<br>");
if (amiga()) document.write("You are using AmigaOS<br>");
if (ppc()) document.write("With a PowerPC processor<br>");
if (intel()) document.write("With an Intel processor<br>");
if (mot()) document.write("With an Motorola 68K processor<br>");
if (document.form.Label1) { //ActiveX Object is there
document.write("You are ActiveX Enabled!<br>")
}
if (!(document.form.Label1)) { //ActiveX is not there
document.write("You are not ActiveX Enabled<br>")
}
// -->
</script> </p>
</div>
</form>

<hr color="#448844" size="1">

<p>
<p align="right"><input type="button" name="view" value="看看源代码" onClick="window.location="view-source:"+window.location.href" class="button"></p>
</td>
</tr>
</table>
</body>
</html>
longyear 2001-05-12
  • 打赏
  • 举报
回复
不会吧!这么复杂!
<HTML>
<HEAD>
<TITLE>浏览器判断</TITLE>
<script language="javascript">
function a()
{
var name=navigator.appName;
var ver=navigator.appVersion;
if (ver.substring(0,1)>="4")
{
if(name=='Netscape')
{
window.alert("你用的浏览器是:Netscape 版本:"+ver);
document.write("Netscape"+ver);
document.close();
return(0);
}

if(name=='Microsoft Internet Explorer')
{
window.alert("你用的浏览器是:IE 版本:"+ver);
document.writeln("IE"+ver);
return(0);
}

else
{
document.writeln("我没用过你的这个浏览器");
window.alert("浏览器:"+name+"版本:"+ver);
return(0);
}
}


else
{
document.writeln("浏览器版本不够4.0以上!!");
window.alert("该浏览器版本小于4.0");
return(0);
}
}
</script>
</HEAD>

<BODY onload="a();">
一 个 关 于 HOME PAGE 浏 览 器 判 断 的 程 序<br>

</BODY>
</HTML>


 

10,606

社区成员

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

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