如何插入JS:
- 直接插入:
<head> <script type="text/javascript"> /*js代码写在这里*/ </script> </head>
- 外部文件插入:
<head> <script src="script.js"></script> /*同时在html同级创建.js文件,直接在.js文件中写js代码*/ </head>
输出内容 document.write():
-
输出形式:
-
document.write("/*此处为输出内容*/");
-
document.write(此处为输出变量);
-
document.write(内容+内容); /*多个内容输出,+连接,类似java*/
警告框alert(字符串或变量):
是否框confirm(str):
提问框prompt(str1,str2):
打开窗口window.open('地址','名称','...'):
- 参数表:
参数 值 意义 top
px数 窗口顶部距屏幕顶部 left px数 窗口左端距屏幕左端 width px数 窗口宽度 height px数 窗口高度 menubar yes,no 有无菜单 toolbar yes,no 有无工具条 scrollbars yes,no 有无滚动条 status yes,no 有无状态栏
关闭窗口xxx.close():
- 关闭本窗口:
window.close();
- 关闭其他窗口:
窗口对象.close(); /*可以把窗口对象储存在变量中*/