JavaScript basic structure
<?xml version= "1.0" encoding= "UTF-8"?><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" Lang="en"> <head> <title>JavaScript basic structure</title> <meta http-equiv="keywords" content="Enter,your,keywords,here" /> <meta http-equiv="description" content="A Short description of The This page. /> <meta http-equiv="Content-type" content="text/html; Charset=utf-8 " /> <script type="text/javascript" src="Js/hello.js"></script> <script type="Text/javascript"> //alert ("Hello JavaScript! "); //document.writeln ("Hello JavaScript!"); varNUM1; num1= -;varNum2= -;varnum1= -;//javascript Case Sensitive //alert (num1+ "," +num2+ "," +num1 "); varflag=true;varheight=180.5;varName="Tom"; hobby="Game";varnum3;varnum4=NULL;vartoday=New Date();varnums=New Array( -, -, -);//alert (hobby); /*alert (typeof (NUM1)); Alert (typeof (flag)); Alert (typeof (height)); Alert (typeof (name)); Alert (typeof (NUM3)); Alert (typeof (NUM4)); Alert (typeof (today)); Alert (typeof (Nums)); */ //switch Selection Structure varweekday="Sunday";Switch(weekday) { Case "Monday": Alert ("The new week has started again, shangfen the same mood!" "); Break; Case "Tuesday": Case "Wednesday": Case "Thursday": Alert ("Work hard, study hard"); Break; Case "Friday": Alert ("It's a holiday tomorrow."); Break;default: Alert ("Sleep to nature awake!" "); Break; }//define an array varnames=New Array("Tom","Alice","Mike.","Jone Sun");//alert (names[2]); //alert (names.length);Names.sort (); Names.reverse (); for(varI=0; i<names.length;i++) {Document.writeln (names[i]); } Document.writeln ("<br/>");//foreach Cycle for(varIinchNames) {Document.writeln (names[i]); }varUsername=prompt ("Please enter your name:",""); Alert (username);</script> </head> <body> <p>This is my XHTML page.</P> <input type="button" value="Point Me" onclick= "alert (' I was ordered to come out of it ')" /><br/> <a href="Javascript:alert (' hehe ')">Hey</a> </body></html>
JavaScript basic structure