<!DOCTYPE html>
<html>
<head>
<title>js1.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<!-- 内部js ,执行顺序与放的位置有关,可放在任意地方-->
<script type="text/javascript">
alert("Hello Word");
var a =3;
alert(a);
a="abc";
alert(a);
var num1=1;
var num2=1.2;
var num3= NaN;
document.write(num1+"<br/>");
document.write(num2+"<br/>");
document.write(num3+"<br/>");
var ch1="ahyvh";
var ch2="字符串";
document.write(ch1+"<br/>");
document.write(ch2+"<br/>");
var bf=true;
var obj1=null;
var obj2=undefined;
var obj3=undefined;
document.write(ch2+"的类型type="+typeof(ch2)+"<br/>");
var a=1;
var b=2;
document.write(a+b+"<br/>");
document.write(a-b+"<br/>");
document.write(a*b+"<br/>");
document.write(a/b+"<br/>");
document.write(a%b+"<br/>");
document.write(("abc">"acb")+"<br/>");
document.write(("123"==123)+"<br/>");
document.write(("123"=== 123)+"<br/>");
var a = 3;
document.write(!!a+"<br/>");
var s="abc";
document.write(!!s+"<br/>");
var n=null;
var u=undefined;
document.write(!!n+"<br/>");
document.write(!!u+"<br/>");
var a=1;
var b=2;
var c=a > b ? 1 : 0;
var b=+"123";
var n1=+true;
var n2=+false;
function fun()
{
b=10;
}
var s;
switch(s)
{
case 1:
alert("number");
break;
case "q":
alert("string");
break;
case null:
alert("null");
break;
case undefined:
alert("undefined");
break;
}
var i=1;
var s=0;
while(i<=100)
{
s+=i;
i++;
}
for(var j=0;j<=100;j++)
{
s+=j;
}
</script>
</head>
<body>
This is my HTML page. <br>
<script type="text/javascript" src="js.js"> </script>
<!-- <script> 标签可以定义多个,要注意在其中需要操作的html元素需要定义在其前面,保证执行的顺序-->
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>js2.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<style type="text/css">
td
{
border:1px solid;
}
</style>
<script type="text/javascript">
document.write("<table align='center'>");
for(var i=1;i<=9;i++)
{
document.write("<tr>");
for(var j=1;j<=i;j++)
{
document.write("<td>");
document.write(i+"*"+j+"="+(i*j)+" ");
document.write("</td>");
}
document.write("</tr>");
}
document.write("</table>");
</script>
</head>
<body>
This is my HTML page. <br>
</body>
</html>