44. Page opening and movement
Add the following code to the <body> area
<SCRIPT LANGUAGE="JavaScript"> <!-- Begin for (t = 2; t > 0; t--) { for (x = 20; x > 0; x--) { for (y = 10; y > 0; y--) { parent.moveBy(0,-x); } } for (x = 20; x > 0; x--) { for (y = 10; y > 0; y--) { parent.moveBy(0,x); } } for (x = 20; x > 0; x--) { for (y = 10; y > 0; y--) { parent.moveBy(x,0); } } for (x = 20; x > 0; x--) { for (y = 10; y > 0; y--) { parent.moveBy(-x,0); } } } //--> // End --> </script> |
45. Display the date and time of the personal client machine
<script language="LiveScript"> <!-- Hiding today = new Date() ***("The current time is: ",today.getHours(),":",today.getMinutes()) ***(" <br>Today's date is: ", today.getMonth()+1,"/",today.getDate(),"/",today.getYear()); // end hiding contents --> </script> |
46. Automatically generate the last modified date for you every time:
<html> <body> This is a simple HTML-page. <br> Last changes: <script language="LiveScript"> <!-- hide script from old browsers ***(document.lastModified) // end hiding contents --> </script> </body> </html> |
47. Cannot be empty and email address constraints:
<html> <head> <script language="JavaScript"> <!-- Hide function test1(form) { if (form.text1.value == "") alert("You didn't write anything, please enter it again!") else { alert("Hi"+form.text1.value+"! You have completed your input!"); } } function test2(form) { if (form.text2.value == "" || form.text2.value.indexOf('@', 0) == -1) alert("This is not the correct e-mail address! Please enter it again!"); else alert("You have completed your input!"); } // --> </script> </head> <body> <form name="first"> Enter your name: <br> <input type="text" name="text1"> <input type="button" name="button1" value="Input test" onClick="test1(this.form)"> <P> Enter your e-mail address: <br> <input type="text" name="text2"> <input type="button" name="button2" value="Input test" onClick="test2(this.form)"> </body> |
48. Marquee
<html> <head> <script language="JavaScript"> <!-- Hide var scrtxt="How about! It's cool! You can also try it."+"Here goes your message the visitors to your page will "+"look at for hours in pure fascination..."; var lentxt=scrtxt.length; var width=100; var pos=1-width; function scroll() { pos++; var scroller=""; if (pos==lentxt) { pos=1-width; } if (pos <0) { for (var i=1; i <=Math.abs(pos); i++) { scroller=scroller+" ";} scroller=scroller+scrtxt.substring(0,width-i+1); } else { scroller=scroller+scrtxt.substring(pos,width+pos); } window.status = scroller; setTimeout("scroll()",150); } //--> </script> </head> <body onLoad="scroll();return true;"> Your web page can be displayed here! </body> </html> |
49. Use buttons in the web page to control the display of the previous page, next page and home page.
<html> <body> <FORM NAME="buttonbar"> <INPUT TYPE="button" VALUE="Back" onClick="history.back()"> <INPUT TYPE="button" VALUE="JS- Home" onClick="location='script.html'"> <INPUT TYPE="button" VALUE="Next" onCLick="history.forward()"> </FORM> </body> </html> |
50. View the source code of a website
Add the following code to the <body> area
<SCRIPT> function add() { var ress=document.forms[0].luxiaoqing.value window.location="view-source:"+ress; } </SCRIPT> Enter the URL address where you want to view the source code: <FORM> <input type="text" name="luxiaoqing" size=40 value="http://"> </FORM> <FORM> <br> <INPUT type="button" value="View source code" onClick=add()> </FORM> |
51. Title displays date
Add the following code to the <body> area:
<script language="JavaScript1.2"> <!--hide var isnMonth = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October ","November","December"); var isnDay = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"); today = new Date () ; Year=today.getYear(); Date=today.getDate(); if(document.all) document.title="Today is: "+Year+"年"+isnMonth[today.getMonth()]+Date+"日"+isnDay[today.getDay()] //--hide--> </script> |