2 JavaScript
2JavaScript JavaScript 2-11hello1.html <html> <head> <title>hello</title> <meta http-equiv="content-type" content="text/html; charset=shift_jis"> </head> <body> <script type="text/javascript" language="javascript"> confirm("hello!"); </script> <p> </p> </body> </html> 54
<script type="text/javascript" language="javascript"> confirm("hello!"); </script> <script> </script> <script> type text javascript language JavaScript type="..." langauge="..." <script> </script> confirm("hello!"); confirm Hello! hello1.html OK 55
2JavaScript 2-1 2-2OK 56
<script> </script> WEB HELP 2-3 JavaScript Windows Intenet Explorer 6.0 2-4 JavaScript Mac OS X Intenet Explorer 5.1 57
2JavaScript <script>...</script> "ab" confirmhello! Hi! Hi! confirm("hi!"); HTML document.write confirm<script>...</ script>document.write <script type="text/javascript" language="javascript"> document.write("<h1>hello!</h1>"); </script> document.write <html> <head> <title>hello</title> <meta http-equiv="content-type" content="text/html; charset=shift_jis"> </head> <body> <h1>hello!</h1> <!-- --> <p> </p> 58
HTML document.write 2-5 document.write </body> </html> document.write 59
2JavaScript <body>...</body><script>...</script> 2-22hello3.html 1 <html> 2 <head> 3 <title>hello</title> 4 <meta http-equiv="content-type" content="text/html; charset=shift_jis"> 5 <script type="text/javascript" language="javascript"> 6 7 function sayhello() { 8 confirm("hello!"); // 9 10 </script> 11 </head> 12 13 <body onload="sayhello()"> 14 <p></p> 15 </body> 16 </html> <body>...</body><script> <head>...</head> <body> onload "sayhello()" <head>...</head> <body>...</body> 60
2-6 <body> onloadsayhello() Hello! onloadsayhello()function onload="xxx" xxx 61
2JavaScript () sayhello() sayhello(){ sayhello() sayhello() confirm() "Hello!" confirm() // // <!-- --> /*... */... /********************************************** * * * 2002.02.14 **********************************************/ 62
if if Hello! confirm() confirm() onload() sayhello() sayhello() <body> onload 2-3hello4.html 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/tr/html4/loose.dtd"> 2 <html> 3 <head> 4 <title>hello</title> 5 <meta http-equiv="content-type" content="text/html; charset=shift_jis"> 6 <script type="text/javascript" language="javascript"> 7 8 function sayhello() { 9 var today; // today 10 var hour; // hour 11 today = new Date(); // Date today 12 hour = today.gethours(); // todayhour 13 14 if (4 <= hour && hour < 10) { // 4 10 15 confirm(""); 63
2JavaScript 16 17 else if (10 <= hour && hour < 19) { // 10 7 18 confirm(""); 19 20 else { // 77 21 confirm(""); 22 23 24 </script> 25 </head> 26 27 <body onload="sayhello()"> 28 <p></p> 29 </body> 30 </html> <!DOCTYPE... sayhello() 9 var today; // today 10 var hour; // hour today hour var 64
if today hour today hour hour our our our 11 today = new Date(); // Date today new Date() Date today Date Date 65
2JavaScript new Date() Date today todaydate 12 hour = today.gethours(); // todayhour todaydate Date get Hours()today.getHours() today.gethours() hour today.getminutes() today.getseconds() today.getfullyear() today.getmonth() == = = x = 3; xx x 3; hour = today.gethours(); ;; hour = today.gethours() ; 66
if today = new Date(); hour = today.gethours() ; ; 14 if (4 <= hour && hour < 10) { // 4 10 15 confirm(""); 16 17 else if (10 <= hour && hour < 19) { // 10 7 18 confirm(""); 19 20 else { // 77 21 confirm(""); 22 23 ifif (4 <= hour && hour < 10) hour hour && hour hour 15 confirm(""); elseelse if hour hour hourhour 18 confirm(""); 67
2JavaScript else 21 confirm(""); if elsevar if else var if = 3; var = else + if; if if... else if... else... if if (<1>) { < 1> else if (<2>) { < 2> else if (<3>) { < 3>... else { < n> else if... else...if else... if 68
< >if < > { { <>truefalse4 <= hour && hour < 10 hourtrue false if if (i+j) { < > i+j if false true <> "" if if (4 <= hour && hour < 10) { // 4 10 confirm(""); 69
2JavaScript ifconfirm() { if (4 <= hour && hour < 10) { confirm(""); // 4 10 if if 2-4 hello5.html 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/tr/html4/loose.dtd"> 2 <!-- hello5.html --> 3 <html> 4 <head> 5 <title>hello</title> 6 <meta http-equiv="content-type" content="text/html; charset=shift_jis"> 7 <script type="text/javascript" language="javascript"> 8 9 function sayhello() { 10 var today; 11 var hour; 12 var month; // month 13 today = new Date(); // Date today 14 hour = today.gethours(); 15 month = today.getmonth()+1; // today month 16 17 if (4 <= month && month <= 9) { // 4 9 70
if if 18 if (4 <= hour && hour < 10) { 19 confirm(""); 20 21 else if (10 <= hour && hour < 19) { 22 confirm(""); 23 24 else { // 74 25 confirm(""); 26 27 28 else { // 1 310 12 29 if (4 <= hour && hour < 10) { 30 confirm(""); 31 32 else if (10 <= hour && hour < 18) { 33 confirm(""); 34 35 else { // 64 36 confirm(""); 37 38 39 40 </script> 41 </head> 42 43 <body onload="sayhello()"> 44 <p></p> 45 </body> 46 </html> today.getmonth() 71
2JavaScript if ifif if 17 if (4 <= month && month <= 9) { //4 9 <A> 28 else { // 1 310 12 <B> <A><B> <A> <B> if <ul> <ol> if ifwhile for 72
if (4 <= hour && hour < 10) { confirm(""); else if (10 <= hour && hour < 18) { confirm(""); else if (18 <= hour && hour < 19) { if (4<=month && month<=9) { // 4 9 confirm(""); else { // 1 310 12 confirm(""); else { // 74 confirm(""); if (4 <= hour && hour < 10) { confirm(""); else if ((10 <= hour && hour < 18) ((18 <= hour && hour< 19) && (4<=month && month<=9) ) ) { confirm(""); else { confirm(""); 73
2JavaScript else if ((10 <= hour && hour < 18) ((18 <= hour && hour< 19) && (4<=month && month<=9))) 10 <= hour && hour < 18(18 <= hour && hour< 19) && (4<=month && month<=9) 18 <= hour && hour< 19 4<=month && month<=9 ( ) (...) else if (10 <= hour && hour < 18 18 <= hour && hour< 19 && 4<=month && month<=9) && < <= < &&&& (...) (...) 74
" '{ () hour our aisatsu aisatu "" 75
2JavaScript WEB HELP if else _ _ $ - _ hello5.html.;...?!. : ; 76
confirm() document.write() confirm() if... else if if (<1>) {... else if (<2>){...... else {... else if <script>...</script> 77
2JavaScript <body onload="()"> confirm() document.write() 78