<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script type="text/javascript">
function disp_alert(){
alert("Äãµã»÷Á˾¯¸æ¿ò£¡");
}
function onmouseoverTest(){
alert("Welcome!");
//document.write("welcome!");
}
function disp_confirm(){
var con=confirm("Are you sure?");
if(con)
//alert("You select sure!");
document.write("Welcome!");
else
alert("You select cancel!");
}
function disp_prompt(){
var name=prompt("ÇëÊäÈëÄãµÄÃû×Ö");
if(name!=null&&name!=""){
document.write("Hello,"+name+"!");
}else{
alert("ÇëÊäÈëÐÕÃû£¡");
}
}
function product(a,b){
return(a*b);
}
function message(){
try{
addalert("Welcome guest!");
}catch(err){
txt="¸ÃÍøÒ³ÓдíÎó£¡\nµã»÷È·¶¨¼ÌÐø²é¿´±¾Ò³¡£\nµã»÷È¡Ïû·µ»ØÖ÷Ò³¡£";
if(!confirm(txt)){
document.location.href="http://www.7789.com";
}
}
}
function judge(){
var number=prompt("Input a number from 0 to 10:","");
try{
if(number<0){
throw "small";
}else if(number>=0&&number<=10){
alert("You are right!");
}else{
throw "large";
}
}catch(err){
if(err=="small")
alert("The input is smaller!");
else if(err=="large")
alert("The input is larger!");
}
}
function checkTime(i){
if(i<10){
i="0"+i;
}
return i;
}
function startTime(){
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
m=checkTime(m);
s=checkTime(s);
document.getElementById("txt").innerHTML=h+":"+m+":"+s;
t=setTimeout("startTime()",500);
}
function getValue(){
var x=document.getElementById("myHeader");
alert(x);
alert(x.innerHTML);//×¢ÒâÆäÖеÄinnerHTMLµÄÊéд£¬·ñÔò»á³ö´íÎó¡£
}
function getElements(){
var x=document.getElementsByName("input");
alert(x);
alert(x.length);
alert(x.innerHTML);
}
function getElementsByTagNameTest(){
var x=document.getElementsByTagName("input");
alert(x.length);
}
function validate_required(field,alertTxt){
with(field){
if(value==null||value==""){
alert(alertTxt);
return false;
}else{
return true;
}
}
}
function validate_email(field,alertTxt){
with(field){
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if(apos<1||(dotapos-apos)<2){
alert(alertTxt);
return false;
}else{
return true;
}
}
}
function validate_form(thisForm){
with(thisForm){
if(validate_required(email,"Email must be filled out!")==false){
email.focus();
return false;
}
if(validate_email(email,"Not a validatde email address!")==false){
email.focus();
return false;
}
}
}
</script>
</head>
<body onload="startTime()">
<script type="text/javascript">
document.write("Hello World!");
var x=5+5;
document.write("<br/>"+x);
var x=5+"5";
document.write("<br>"+x);
var x="5"+5;
document.write("<br>"+x);
var x="5"+"5";
document.write("<br>"+x);
var x=5;
document.write("<br>"+(x==="5"));//×¢ÒâÒª¼Ó()£¬·ñÔò²»°´¹æÔòÀ´
document.write("<br>"+x);
document.write("<br>"+(x===5));//×¢ÒâÒª¼Ó()£¬·ñÔò²»°´¹æÔòÀ´£¬´ð°¸Îªfalse
var x=10;
var result=(x>9)?"Too young!":"Too old!";
document.write("<br>"+result+"<br>");
switch(x){
case 11:
document.write("10");
break;
case 15:
document.write("15");
break;
case 6:
document.write("6");
break;
case 0:
document.write("0");
break;
default:
document.write("Nothing");
}
document.write("<br>2*3="+product(2,3)+"<br>");
for(i=0;i<10;i++){
document.write("<h"+i+">±êÌâ"+i+"</h"+i+"><br>");
}
var array=new Array("1","2","3","4","5");
for(x in array){
document.write(array[x]+"<br>");
}
var txt="Hello,\"John\",sdfgdf";
document.write(txt);
document.write("<br>You \& me are singing!");
document.write("<br>Hello \
everyone!<br>");
//¶ÔÏó
var str="Hello world!";
document.write(str.length+"<br>");//ÕâÀïµÄµ¥´ÊÊý²»°üÀ¨¿Õ¸ñ
document.write(str.toUpperCase()+"<br>");
document.write(str.toLowerCase()+"<br>");
document.write(str.replace("!","!!!"));
//ʱ¼ä
document.write(Date());
//Êý×é
var array1=new Array("0","1","2","3","4","5");
var array2=new Array("h","f","a","b","c","d","e");
document.write("<br>"+array1);
document.write("<br>"+array1.concat(array2));
document.write("<br>"+array1);
document.write("<br>"+array1.join("."));
document.write("<br>"+array2.sort());
//boolean
var b=new Boolean();//×¢ÒâÇ°ÃæµÄÉùÃ÷Ϊvar£¬¶ø²»ÊÇBoolean¡£
document.write(b);
var b=new Boolean(0);
document.write(b);
var b=new Boolean(false);
document.write(b);
var b=new Boolean(true);
document.write(b);
var b=new Boolean("false");
document.write(b);
//math
document.write("<br>"+Math.random());
document.write("<br>"+Math.round(5.2));
document.write("<br>"+Math.floor(Math.random()*12));
//ÕýÔò±í´ïʽ
re=new RegExp("ex");
document.write("<br>"+re.test("Hello every one!"));
document.write("<br>"+re.test("expression"));
document.write("<br>"+re.exec("Hello world! expression"));
re=new RegExp("e","g");
do{
result=re.exec("The best thing in the life is free!");
document.write(result);
}while(result!=null)
var re=new RegExp("e");
document.write(re.exec("The best thing in the life is free!"));
re.compile("g");
document.write(re.test("The best thing in the life is free!"));
document.writeln("<br>"+document.referrer);
document.writeln("<br>"+navigator.cupClass);
document.writeln("<br>"+location.port);
</script>
<div id="txt"></div>
<br/>
<input type="button" onclick="disp_alert()" value="¾¯¸æ¿ò"/><br/>
<input type="text" onmouseover="onmouseoverTest()"/><br/>
<p onmouseover="onmouseoverTest()">½«Êó±ê·ÅÉÏÀ´ÊÔһϣ¡</p><br/>
<a href="" onmouseover="onmouseoverTest()">½«Êó±ê·ÅÉÏÀ´ÊÔһϣ¡</a><br/>
<input type="button" onclick="disp_confirm()" value="½øÈë"/><br/>
<input type="button" onclick="disp_prompt()" value="×¢²á"/><br/>
<a href="http://www.7789.com"><img src="logo.jpg"/></a><br/>
<a href="http://www.7789.com" onmouseover="onmouseoverTest()"><img src="logo.jpg"/></a><br/>
<input type="button" onclick="message()" value="Ñ¡Ôñ"/><br/>
<input type="button" onclick="judge()" value="ÅжÏ"/><br/>
<p id="txt"></p>
<h1 id="myHeader" onclick="getValue()">±êÌâ1</h1>
<input type="text" name="input"/>
<input type="text" name="input"/>
<input type="text" name="input"/>
<input type="button" onclick="getElements()" value="getElementsByName"/>
<input type="button" onclick="getElementsByTagNameTest()" value="getElementsByTagName"/>
<form action="email.php" onsubmit="return validate_form(this)" method="post">
Email:<input type="text" name="email" size="30"/>
<input type="submit" value="submit"/>
</form>
</body>
</html>