最简单的格式
- <html>
- <head>
- <title>菜鸡</title>
- <body>
- <h1>菜</h1>
- <h2>鸡</h2>
- </body>
- </html>
h后面的数字越小字体越大

位于script标签中间
1、var定义变量

感觉写法跟python差不多,输出不同
2、标识符
javascript对大小写敏感,目前见到的好像就sql对大小写不敏感
3、赋值运算符
=是赋值,==是等于
4、DOM操作
(1)获取HTML元素:getElementById()
- <html>
- <head>
- <title>
- 中国
- </title>
- </head>
- <body>
- <p id="taiwan">台湾是中国领土主权不可分割的一部分</p>
- <script>x=document.getElementById("taiwan")</script>
- </body>
- </html>

(2)获取HTML元素内容:innerHTML()
- <html>
- <head>
- <title>
- 中国
- </title>
- </head>
- <body>
- <p id="taiwan">台湾是中国领土主权不可分割的一部分</p>
- <script>
- x=document.getElementById("taiwan");
- alert('id为taiwan元素的内容是:'+x.innerHTML);
- </script>
- </body>
- </html>

(3)添加动态效果
document.write() 写入 HTML 输出,会清除已有html
console.log() 写入浏览器控制台document.write(Date())写入时间

document.write("<iframe src='http://www.heetian.com'></iframe>");写入框架

onclick事件属性
- <html>
- <head>
- <title>
- 菜鸡本鸡
- </title>
- </head>
- <body>
- <p id="taiwan"><h1>菜鸡</h1></p>
- <script>
- function ti(id)
- {
- id.innerHTML="是你";
- }
- </script>
- <h2 onclick="ti(this)">点击这里</h2>
- </body>
- </html>
5、BOM操作
alert()警告弹窗

confirm() 确定弹窗

prompt()提示弹窗

document.cookie获取cookie信息
window:客户端JavaScript中的顶层对象。每当<body>或<frameset>标签出现时,window对象就会被自动创建
navigator:包含客户端有关浏览器的信息
screen:包含客户端显示屏的信息
history:包含浏览器窗口访问过的URL信息
location:包含当前网页文档的URL信息
document:包含整个HTML文档,可被用来访问文档内容,及其所有页面元素
http://www.runoob.com/http/http-tutorial.html
web服务端架构