File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > Document</ title >
6+ </ head >
7+ < body >
8+ < script >
9+ function newDoc ( ) {
10+ window . location . assign ( "http://www.baidu.com" ) ;
11+ }
12+ </ script >
13+ < input type ="button " value ="加载新文档 " onclick ="newDoc() ">
14+ </ body >
15+ </ html >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > Document</ title >
6+ < script >
7+ var c = 0 ;
8+ var t ;
9+ function timedCount ( ) {
10+ document . getElementById ( 'txt' ) . value = c ;
11+ c = c + 1 ;
12+ t = setTimeout ( "timedCount()" , 1000 ) ;
13+ }
14+ function stopCount ( ) {
15+ c = 0 ;
16+ setTimeout ( "document.getElementById('txt').value=0" , 0 ) ;
17+ clearTimeout ( t ) ;
18+ }
19+ </ script >
20+ </ head >
21+ < body >
22+ < form >
23+ < input type ="button " name ="1 " onclick ="timedCount() " value ="开始计时 ">
24+ < input type ="text " name ="2 " id ="txt ">
25+ < input type ="button " name ="3 " value ="停止计时 " onclick ="stopCount() ">
26+ </ form >
27+ </ body >
28+ </ html >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > Document</ title >
6+ </ head >
7+ < body >
8+ < script >
9+ function disp_prompt ( ) {
10+ var name = prompt ( "请输入你的名字" , "Bill Gates" ) ;
11+ if ( name != null && name != "" ) {
12+ document . write ( "您好!" + name + ",今天过的怎么样?" )
13+ }
14+ }
15+ </ script >
16+ < input onclick ="disp_prompt() " value ="显示提示框 " type ="button "> </ input >
17+ </ body >
18+ </ html >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > Document</ title >
6+ </ head >
7+ < body >
8+ < script >
9+ var a = new RegExp ( "e" ) ;
10+ document . write ( a . test ( "the best thing in life are free" ) + "<br>" ) ;
11+ document . write ( a . exec ( "the best thing in life are free" ) + "<br>" ) ;
12+
13+ var b = new RegExp ( "e" , "g" ) ;
14+ do {
15+ result = b . exec ( "the best thing in life are free" + "<br>" ) ;
16+ document . write ( result ) ;
17+ }
18+ while ( result != null ) ;
19+
20+ var c = new RegExp ( "e" ) ;
21+ document . write ( a . test ( "the best thing in life are free" ) + "<br>" ) ;
22+ a . compile ( "d" ) ;
23+ document . write ( a . test ( "the best thing in life are free" ) + "<br>" ) ;
24+
25+ </ script >
26+ </ body >
27+ </ html >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > Document</ title >
6+ </ head >
7+ < body >
8+ < p id ="demo "> </ p >
9+ < script >
10+ var H = window . innerHeight
11+ || document . documentElement . clientHeight
12+ || document . body . clientHeight ;
13+ var W = window . innerWidth
14+ || document . documentElement . clientWidth
15+ || document . body . clientWidth ;
16+
17+ x = document . getElementById ( "demo" ) ;
18+ x . innerHTML = "浏览器窗口高度:" + H + ",宽度:" + H + "。" ;
19+
20+ document . write ( "可用宽度:" + screen . availWidth + "<br>" ) ;
21+ document . write ( "可用高度:" + screen . availHeight + "<br>" ) ;
22+ </ script >
23+
24+ </ body >
25+ </ html >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > Document</ title >
6+ </ head >
7+ < body >
8+ < script >
9+ document . write ( Math . round ( 0.66 ) + "<br>" ) ;
10+ document . write ( Math . random ( ) * 10 + 1 + "<br>" ) ;
11+ document . write ( Math . random ( ) * 11 + "<br>" )
12+ document . write ( Math . max ( 2.1 , 34 ) + "<br>" ) ;
13+ document . write ( Math . min ( 22 , 1.1 ) + "<br>" ) ;
14+ document . write ( Math . E + "<br>" ) ;
15+ document . write ( Math . PI + "<br>" ) ;
16+ document . write ( Math . LN2 ) ;
17+ </ script >
18+ </ body >
19+ </ html >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > Document</ title >
6+ </ head >
7+ < body >
8+ < script type ="text/javascript ">
9+ function disp_alert ( ) {
10+ alert ( "再次向你问好!在这里,我们向您演示" + "\n" + "如何向警告框这行。" + "<br>" )
11+ }
12+
13+ function show_confirm ( ) {
14+ var r = confirm ( "you pressd ok" ) ;
15+ if ( r == true ) {
16+ alert ( "You perssed ok!" )
17+ }
18+ else {
19+ alert ( "You pressed Cancel" ) ;
20+ }
21+ }
22+ </ script >
23+ < input type ="button " name ="we " value ="显示警告框 " onclick ="disp_alert() ">
24+ < input type ="button " value ="Show a confirm box " onclick ="show_confirm() ">
25+ </ body >
26+ </ html >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > Document</ title >
6+ </ head >
7+ < body >
8+ < script >
9+ function setmedMsg ( ) {
10+ var t = setTimeout ( "alert('5秒!')" , 1000 ) ;
11+
12+ }
13+ </ script >
14+ < input type ="button " name ="1 " value ="显示定时的警告框 " onclick ="setmedMsg() ">
15+ </ body >
16+ </ html >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > Document</ title >
6+ </ head >
7+ < body >
8+ < script >
9+ function timedText ( ) {
10+ var t1 = setTimeout ( "document.getElementById('txt').value='2秒'" , 2000 ) ;
11+ var t2 = setTimeout ( "document.getElementById('txt').value='4秒'" , 4000 ) ;
12+ var t3 = setTimeout ( "document.getElementById('txt').value='6秒'" , 6000 ) ;
13+ }
14+ </ script >
15+ < form >
16+ < input type ="button " name ="1 " value ="显示计时的文本 " onclick ="timedText() ">
17+ < input type ="text " name ="2 " id ="txt ">
18+ < p > 点击上面的按钮,输入框会显示已经逝去的时间(2,4,6秒)</ p >
19+ </ form >
20+ </ body >
21+ </ html >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > Document</ title >
6+ < script >
7+ function startTime ( ) {
8+ var d = new Date ( ) ;
9+ var h = d . getHours ( ) ;
10+ var m = d . getMinutes ( ) ;
11+ var s = d . getSeconds ( ) ;
12+ //checkTime()小于10的前面加0
13+ m = checkTime ( m ) ;
14+ s = checkTime ( s ) ;
15+ document . getElementById ( 'txt' ) . innerHTML = h + ":" + m + ":" + s ;
16+ t = setTimeout ( 'startTime()' , 500 ) ;
17+ }
18+ function checkTime ( i ) {
19+ if ( i < 10 ) {
20+ i = "0" + i ;
21+ }
22+ return i ;
23+ }
24+ </ script >
25+ </ head >
26+ < body onload ="startTime() ">
27+ < div id ="txt "> </ div >
28+ </ body >
29+ </ html >
You can’t perform that action at this time.
0 commit comments