<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>JavaScript页面</title>
<script language="javascript">
var myName = "isaac";
document.write(myName);
</script>
</head>
<body>
<p>正文内容</p>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>slice()和substring()</title>
<script language="javascript">
var sMyString = "Tsinghua University";
document.write(sMyString.slice(1,3) + "<br>");
document.write(sMyString.substring(1,3) + "<br>");
document.write(sMyString.slice(4) + "<br>");
document.write(sMyString + "<br>"); //不改变原字符串
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>slice()和substring()的区别</title>
<script language="javascript">
var sMyString = "Tsinghua University";
document.write(sMyString.slice(2,-3) + "<br>");
document.write(sMyString.substring(2,-3) + "<br>");
document.write(sMyString.substring(2,0) + "<br>");
document.write(sMyString + "<br>");
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>indexOf()和lastIndexOf()</title>
<script language="javascript">
var sMyString = "Tsinghua University";
document.write(sMyString.indexOf("i")+"<br>"); //从前往后
document.write(sMyString.indexOf("i",3)+"<br>"); //可选参数,从第几个字符开始往后找
document.write(sMyString.lastIndexOf("i")+"<br>"); //从后往前
document.write(sMyString.lastIndexOf("i",3)+"<br>"); //可选参数,从第几个字符开始往前找
document.write(sMyString.lastIndexOf("V")+"<br>"); //大写“V”找不到,返回-1
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>数值计算</title>
<script language="javascript">
var mynum1 = 23.345;
var mynum2 = 45;
var mynum3 = -34;
var mynum4 = 9e5; //科学计数法
alert(mynum1 + " " + mynum2 + " " + mynum3 + " " + mynum4);
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>数值计算</title>
<script language="javascript">
var fNumber = 895.4;
alert(fNumber.toExponential(1));
alert(fNumber.toExponential(2));
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>布尔型</title>
<script language="javascript">
var married = true;
alert("1." + typeof(married));
married = "true";
alert("2." + typeof(married));
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>类型转换</title>
<script language="javascript">
var a = 3;
var b = a + "";
var c = a.toString();
var d = "student" + a;
alert(typeof(a) + " " + typeof(b) + " " + typeof(c) + " " + typeof(d));
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>toString()方法</title>
<script language="javascript">
var a=11;
document.write(a.toString(2) + "<br>");
document.write(a.toString(3) + "<br>");
document.write(a.toString(8) + "<br>");
document.write(a.toString(16) + "<br>");
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>parseInt()方法</title>
<script language="javascript">
document.write(parseInt("4567red") + "<br>");
document.write(parseInt("53.5") + "<br>");
document.write(parseInt("0xC") + "<br>"); //直接进制转换
document.write(parseInt("isaacshun@gmail.com") + "<br>");
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>parseInt()方法</title>
<script language="javascript">
document.write(parseInt("AF",16) + "<br>");
document.write(parseInt("11",2) + "<br>");
document.write(parseInt("011") + "<br>"); //0开头,默认为八进制
document.write(parseInt("011",8) + "<br>");
document.write(parseInt("011",10) + "<br>"); //指定为十进制
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>parseFloat()方法</title>
<script language="javascript">
document.write(parseFloat("34535orange") + "<br>");
document.write(parseFloat("0xA") + "<br>"); //不再有默认进制,直接输出第一个字符“0”
document.write(parseFloat("435.34") + "<br>");
document.write(parseFloat("435.34.564") + "<br>");
document.write(parseFloat("isaacshun@gmail.com") + "<br>");
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>数组</title>
<script language="javascript">
var aMap = new Array("China","USA","Britain");
alert(aMap.length + " " + aMap[2]);
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>数组</title>
<script language="javascript">
var aMap = new Array("China","USA","Britain");
aMap[20] = "Korea";
alert(aMap.length + " " + aMap[10] + " " + aMap[20]);
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>数组</title>
<script language="javascript">
var aMap = ["China","USA","Britain"];
aMap[20] = "Korea";
alert(aMap.length + " " + aMap[10] + " " + aMap[20]);
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>数组</title>
<script language="javascript">
var aMap = ["China","USA","Britain"];
alert(aMap.toString() + " " + typeof(aMap.toString()));
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>join()方法</title>
<script language="javascript">
var aMap = ["China","USA","Britain"];
document.write(aMap.join() + "<br>"); //无参数,等同于toString()
document.write(aMap.join("") + "<br>"); //不用连接符
document.write(aMap.join("][") + "<br>"); //用“][”来连接
document.write(aMap.join("-isaac-") + "<br>");
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>split()方法</title>
<script language="javascript">
var sFruit = "apple,pear,peach,orange";
var aFruit = sFruit.split(",");
alert(aFruit.join("--"));
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>reverse()方法</title>
<script language="javascript">
var aFruit = ["apple","pear","peach","orange"];
alert(aFruit.reverse().toString());
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>字符串的reverse()</title>
<script language="javascript">
var sMyString = "abcdefg";
alert(sMyString.split("").reverse().join(""));
/* split("")将每一个字符转为一个数组元素
reverse()反序数组的每个元素
join("")再最后将数组无连接符的转为字符串
*/
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>sort()方法</title>
<script language="javascript">
var aFruit = ["pear","apple","peach","orange"];
aFruit.sort();
alert(aFruit.toString());
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>ջ</title>
<script language="javascript">
var stack = new Array();
stack.push("red");
stack.push("green");
stack.push("blue");
document.write(stack.toString() + "<br>");
var vItem = stack.pop();
document.write(vItem + "<br>");
document.write(stack.toString());
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<script language="javascript">
document.write("Pear" == "Pear");
document.write("<br>");
document.write("Apple" < "Orange");
document.write("<br>");
document.write("apple" < "Orange");
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<script language="javascript">
document.write(3>2 && 4>3);
document.write("<br>");
document.write(3>2 && 4<3);
document.write("<br>");
document.write(4<3 || 3>2);
document.write("<br>");
document.write(!(3>2));
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>if语句</title>
</head>
<body>
<script language="javascript">
//首先获取用户的一个输入,并用Number()强制转换为数字
var iNumber = Number(prompt("输入一个5到100之间的数字", ""));
if(isNaN(iNumber)) //判断输入的是否是数字
document.write("请确认你的输入正确");
else if(iNumber > 100 || iNumber < 5) //判断输入的数字范围
document.write("你输入的数字范围不在5和100之间");
else
document.write("你输入的数字是:" + iNumber);
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>switch语句</title>
</head>
<body>
<script language="javascript">
iWeek = parseInt(prompt("输入1到7之间的整数",""));
switch(iWeek){
case 1:
document.write("Monday");
break;
case 2:
document.write("Tuesday");
break;
case 3:
document.write("Wednesday");
break;
case 4:
document.write("Thursday");
break;
case 5:
document.write("Friday");
break;
case 6:
document.write("Saturday");
break;
case 7:
document.write("Sunday");
break;
default:
document.write("Error");
}
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>while语句</title>
</head>
<body>
<script language="javascript">
var i=iSum=0;
while(i<=100){
iSum += i;
i++;
}
alert(iSum);
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>do..while语句</title>
</head>
<body>
<script language="javascript">
var aNumbers = new Array();
var sMessage = "你输入了:\n";
var iTotal = 0;
var vUserInput;
var iArrayIndex = 0;
do{
vUserInput = prompt("输入一个数字,或者'0'退出","0");
aNumbers[iArrayIndex] = vUserInput;
iArrayIndex++;
iTotal += Number(vUserInput);
sMessage += vUserInput + "\n";
}while(vUserInput != 0) //当输入为0(默认值)时退出循环体
sMessage += "总数:" + iTotal;
alert(sMessage);
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>for语句</title>
</head>
<body>
<script language="javascript">
var aNumbers = new Array();
var sMessage = "你输入了:\n";
var iTotal = 0;
var vUserInput;
var iArrayIndex = 0;
do{
vUserInput = prompt("输入一个数字,或者'0'退出","0");
aNumbers[iArrayIndex] = vUserInput;
iArrayIndex++;
}while(vUserInput != 0) //当输入为0(默认值)时退出循环体
//for循环遍历数组的常用方法:
for(var i=0;i<aNumbers.length;i++){
iTotal += Number(aNumbers[i]);
sMessage += aNumbers[i] + "\n";
}
sMessage += "总数:" + iTotal;
alert(sMessage);
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>break语句</title>
</head>
<body>
<script language="javascript">
var aNumbers = new Array();
var sMessage = "你输入了:<br>";
var iTotal = 0;
var vUserInput;
var iArrayIndex = 0;
do{
vUserInput = Number(prompt("输入一个数字,或者'0'退出","0"));
if(isNaN(vUserInput)){
document.write("输入错误,请输入数字,'0'退出<br>");
break; //输入错误直接退出整个do循环体
}
aNumbers[iArrayIndex] = vUserInput;
iArrayIndex++;
}while(vUserInput != 0) //当输入为0(默认值)时退出循环体
//for循环遍历数组的常用方法:
for(var i=0;i<aNumbers.length;i++){
iTotal += Number(aNumbers[i]);
sMessage += aNumbers[i] + "<br>";
}
sMessage += "总数:" + iTotal;
document.write(sMessage);
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>continue语句</title>
</head>
<body>
<script language="javascript">
var aNumbers = new Array();
var sMessage = "你输入了:<br>";
var iTotal = 0;
var vUserInput;
var iArrayIndex = 0;
do{
vUserInput = Number(prompt("输入一个数字,或者'0'退出","0"));
if(isNaN(vUserInput)){
alert("输入错误,请输入数字,'0'退出");
continue; //输入错误则退出当前循环,继续下一次循环
}
aNumbers[iArrayIndex] = vUserInput;
iArrayIndex++;
}while(vUserInput != 0) //当输入为0(默认值)时退出循环体
//for循环遍历数组的常用方法:
for(var i=0;i<aNumbers.length;i++){
iTotal += Number(aNumbers[i]);
sMessage += aNumbers[i] + "<br>";
}
sMessage += "总数:" + iTotal;
document.write(sMessage);
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>九九乘法表</title>
</head>
<body bgcolor="#e0f1ff">
<table cellpadding="6" cellspacing="0" style="border-collapse:collapse; border:none;">
<script language="javascript">
for(var i=1;i<10;i++){ //乘法表一共九行
document.write("<tr>"); //每行是table的一行
for(j=1;j<10;j++) //每行都有9个单元格
if(j<=i) //有内容的单元格
document.write("<td style='border:2px solid #004B8A; background:#FFFFFF;'>"+i+"*"+j+"="+(i*j)+"</td>");
else //没有内容的单元格
document.write("<td style='border:none;'></td>");
document.write("</tr>");
}
</script>
</table>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>arguments.length</title>
<script language="javascript">
function ArgsNum(){
return arguments.length;
}
document.write(ArgsNum("isaac",25) + "<br>");
document.write(ArgsNum() + "<br>");
document.write(ArgsNum(3) + "<br>");
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>arguments</title>
<script language="javascript">
function fnAdd(){
if(arguments.length == 0)
return;
else if(arguments.length == 1)
return arguments[0] + 5;
else{
var iSum = 0;
for(var i=0;i<arguments.length;i++)
iSum += arguments[i];
return iSum;
}
}
document.write(fnAdd(45) + "<br>");
document.write(fnAdd(45,50) + "<br>");
document.write(fnAdd(45,50,55,60) + "<br>");
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>杨辉三角</title>
<script language="javascript">
function Combination(m,n){
if(n==0) return 1; //每行第一个数为1
else if(m==n) return 1; //最后一个数为1
//其余都是上一行相邻元素相加而来
else return Combination(m-1,n-1)+Combination(m-1,n);
}
function Pascal(n){ //杨慧三角,n为行数
for(var i=0;i<n;i++){ //一共n行
for(var j=0;j<=i;j++) //每行数字的个数即为行号,例如第一行1个数,第二行2个数
document.write(Combination(i,j)+" ");
document.write("<br>");
}
}
Pascal(10); //直接传入希望得到的杨辉三角的行数
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Date对象</title>
<script language="javascript">
var myDate1 = new Date(); //运行代码前的时间
for(var i=0;i<3000000;i++);
var myDate2 = new Date(); //运行代码后的时间
alert(myDate2-myDate1);
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Date对象</title>
<script language="javascript">
var oMyDate = new Date();
var iYear = oMyDate.getFullYear();
var iMonth = oMyDate.getMonth() + 1; //月份是从0开始的
var iDate = oMyDate.getDate();
var iDay = oMyDate.getDay();
switch(iDay){
case 0:
iDay = "星期日";
break;
case 1:
iDay = "星期一";
break;
case 2:
iDay = "星期二";
break;
case 3:
iDay = "星期三";
break;
case 4:
iDay = "星期四";
break;
case 5:
iDay = "星期五";
break;
case 6:
iDay = "星期六";
break;
default:
iDay = "error";
}
document.write("今天是" + iYear + "年" + iMonth +"月" + iDate + "日," + iDay);
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Date对象</title>
<script language="javascript">
function disDate(oDate, iDate){
var ms = oDate.getTime(); //换成毫秒数
ms -= iDate*24*60*60*1000; //计算相差的毫秒数
return new Date(ms); //返回新的时间对象
}
var oBeijing = new Date(2008,7,8);
var iNum = 100; //前100天
var oMyDate = disDate(oBeijing, iNum);
document.write(oMyDate.getFullYear()+"年"+(oMyDate.getMonth()+1)+"月"+oMyDate.getDate()+"日" + "距离"+oBeijing.getFullYear()+"年"+(oBeijing.getMonth()+1)+"月"+oBeijing.getDate()+"日为"+iNum+"天");
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Math.random()</title>
<script language="javascript">
function selectFrom(iFirstValue, iLastValue){
var iChoices = iLastValue - iFirstValue + 1; //计算项数
return Math.floor(Math.random()*iChoices+iFirstValue);
}
var iNum = selectFrom(2,99); //随机选择数字
var aFruits = ["apple","pear","peach","orange","watermelon","banana"];
//随机选择数组元素
var sFruit = aFruits[selectFrom(0,aFruits.length-1)];
alert(iNum + " " + sFruit);
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>检测浏览器和操作系统</title>
<script language="javascript">
var sUserAgent = navigator.userAgent;
//检测Opera、KHTML
var isOpera = sUserAgent.indexOf("Opera") > -1;
var isKHTML = sUserAgent.indexOf("KHTML") > -1 || sUserAgent.indexOf("Konqueror") > -1 || sUserAgent.indexOf("AppleWebKit") > -1;
//检测IE、Mozilla
var isIE = sUserAgent.indexOf("compatible") > -1 && sUserAgent.indexOf("MSIE") > -1 && !isOpera;
var isMoz = sUserAgent.indexOf("Gecko") > -1 && !isKHTML;
//检测操作系统
var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh");
var isUnix = (navigator.platform == "X11") && !isWin && !isMac;
if(isOpera) document.write("Opera ");
if(isKHTML) document.write("KHTML ");
if(isIE) document.write("IE ");
if(isMoz) document.write("Mozilla ");
if(isWin) document.write("Windows");
if(isMac) document.write("Mac");
if(isUnix) document.write("Unix");
</script>
</head>
<body>
</body>
</html>
分享到:
相关推荐
JavaScript基础语法(ppt)JavaScript基础语法(ppt)JavaScript基础语法(ppt)JavaScript基础语法(ppt)JavaScript基础语法(ppt)JavaScript基础语法(ppt)JavaScript基础语法(ppt)JavaScript基础语法(ppt)...
《javascript基础教程(第8版)》循序渐进地讲述了javascript 及相关的css、dom、ajax、jquery 等技术。书中从javascript 语言基础开始,分别讨论了图像、框架、浏览器窗口、表单、正则表达式、用户事件和cookie,并...
本教程旨在为初学者提供一个全面的JavaScript基础知识学习平台,帮助理解并掌握这种强大的脚本语言。 《JavaScript基础教程》首先会介绍JavaScript的历史背景和基本语法,包括变量、数据类型、操作符、流程控制...
这个资源是javaScript基础语法的总结,适合学完javascript基础语法的进行巩固、复习! 这...我是想免费给大家看的,这怎么还收费
总的来说,这个压缩包提供了一个全面的JavaScript基础知识教程,涵盖了数据类型、Object、内置对象和变量等核心概念,对于初学者或者需要巩固基础的开发者来说,是一份非常有价值的参考资料。通过学习这些内容,可以...
《JavaScript基础与案例开发详解》根据JavaScript在各种类型的应用开发中(如B2B、B2C、C2C)的使用情况,有针对性地安排了丰富的案例,从基本的表格操作、表单操作,到构建浏览器端的富文本编辑器,再到实现像Windows...
JavaScript 基础教程 JavaScript 是一种广泛应用于网页和网络应用的轻量级编程语言,它主要用于增强网页的交互性和动态功能。JavaScript 能够直接嵌入 HTML 页面中,为设计师提供了一种无需深入编程就能实现动态...
资源名称:Javascript基础与案例开发详解内容简介:《Java script基础与案例开发详解》根据Javascript在各种类型的应用开发中(如B2B、B2C、C2C)的使用情况,有针对性地安排了丰富的案例,从基本的...
javascript 基础 教程 入门 精通 javascript 基础 教程 入门 精通 javascript 基础 教程 入门 精通 javascript 基础 教程 入门 精通 javascript 基础 教程 入门 精通 javascript 基础 教程 入门 精通 javascript ...
JavaScript基础三天总结
本“JavaScript基础手册”旨在帮助初学者全面掌握JavaScript的核心概念和技术。 JavaScript语法基于ECMAScript规范,它包括变量、数据类型(如字符串、数字、布尔值、null、undefined、对象和数组)、运算符(算术...
这个"Javascript基础教程版"涵盖了JavaScript的核心概念,旨在为初学者提供一个清晰的学习路径。 在JavaScript的基础教程中,你将首先了解它的历史背景和应用领域,然后深入到语法层面。JavaScript语法基于...
这个名为"JavaScript基础大全 (1-4) 学习必备珍藏品"的资源显然是一个系列教程,包含了从初级到进阶的JavaScript基础知识。让我们深入探讨一下JavaScript的核心概念和技术。 1. **基础语法**:JavaScript是一种...
本资源“javascript基础视频80集11”包含了80个视频教程,覆盖了JavaScript的基础概念到高级特性,适合初学者进行系统学习。 在JavaScript的基础阶段,通常会涉及以下知识点: 1. **变量与数据类型**:JavaScript...
### JavaScript基础教程核心知识点概述 #### 一、JavaScript简介与特性 - **JavaScript的作用**:JavaScript主要用于增强网页的交互性和动态效果,使网页能够实时响应用户的操作,提高用户体验。 - **减少HTML重复*...
本套“JavaScript基础视频80集8”将深入浅出地介绍这一语言的基础知识,帮助初学者建立坚实的编程基础。 视频内容可能涵盖以下几个方面: 1. **变量与数据类型**:JavaScript支持多种数据类型,包括基本类型(如...
本教程“JavaScript基础与实例教程”由中国电力出版社出版,旨在为初学者和有经验的开发者提供一个深入理解JavaScript核心概念和实践技巧的平台。 首先,JavaScript的核心概念包括变量、数据类型和操作符。变量是...
这个“JavaScript基础教程”PDF文件是初学者掌握JavaScript语法和概念的理想资源。下面,我们将深入探讨JavaScript的核心知识,包括变量、数据类型、控制流、函数、对象、数组、DOM操作以及事件处理等。 1. **变量...
在这个"JavaScript基础教程"中,我们将深入探讨JavaScript的核心概念和常见用法。 1. **基础语法** JavaScript的基础包括变量声明(var、let、const)、数据类型(如字符串、数字、布尔值、null、undefined、对象...