window.alert("hello") 提醒
ret=window.confirm() 确定返回true,取消返回false
window.promot() 接收用户信息文本
open(url) 打开新的浏览器窗口
close() 关闭
setInterval(f,1000) 设定定时,每秒执行f()
new Date() 创建当前时间
clearInterval(setInterval(f,1000)) 取消定时
setTimeout(f,1000) 一秒后执行f()
var clock 没有var代表全局变量

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> #id1{ width: 200px; height: 50px; } </style> </head> <body> <input type="text" id="id1" onclick="begin()"> <button onclick="end()">停止</button> <script> function showTime() { var current_time=new Date().toLocaleString(); var ele=document.getElementById("id1") ele.value=current_time } // var clock1; function begin() { // if(clock1==undefined){ showTime(); clock1=setInterval(showTime,1000) // } } function end() { clearInterval(clock1); clock1=undefined } </script> </body> </html>