├── examples
├── 第25章-新兴的API
│ ├── test0.txt
│ ├── test1.txt
│ ├── test2.txt
│ ├── test3.txt
│ ├── test4.txt
│ ├── genTestFile.js
│ ├── file3.html
│ ├── files.html
│ └── files2.html
├── imgs
│ ├── drawing.jpeg
│ └── async-defer-script.png
├── 第20章-JSON
│ └── testNodeJson.js
├── 第16章-HTML5脚本编程
│ ├── post-message-iframe.html
│ ├── post-message-parent.html
│ └── drag.html
├── 第13章-事件
│ ├── dom0-event.html
│ ├── attachEvent.html
│ ├── event-attrs.html
│ ├── dom2-event2.html
│ ├── dom2-event.html
│ ├── event.html
│ ├── event-fn.html
│ └── addHandler.html
├── 第5章-引用类型
│ ├── iframe父窗口.html
│ └── iframe子窗口.html
├── 第14章-表单脚本
│ ├── form.html
│ ├── paste.html
│ ├── input.html
│ ├── auto-focus.html
│ └── button-type.html
├── 第15章-canvas
│ ├── canvas2.html
│ ├── canvas3.html
│ ├── canvas1.html
│ ├── canvas5.html
│ ├── canvas4.html
│ └── time.html
├── 第21章-Ajax与Comet
│ └── 测试activeXString.html
└── 第十章-DOM
│ └── 操作节点.html
├── package.json
├── 第2章-在html中使用JavaScript.md
├── 第20章-Json.md
├── .gitignore
├── gulpfile.js
├── 第17章-错误处理与调试.md
├── 第23章-离线应用与客户端存储.md
├── 第8章-BOM.md
├── LICENSE
├── 第16章-HTML5脚本编程.md
├── 第3章-基本概念.md
├── README.md
├── 第10-DOM.md
├── 第25章-新兴的API.md
├── 第4章-变量、作用域和内存问题.md
├── 第9章-客户端检测.md
├── 第22章-高级技巧.md
├── 第6章-面向对象的程序设计.md
├── 第15章-使用canvas绘图.md
├── 第7章-函数表达式.md
├── 第13章-事件.md
├── 第14章-表单脚本.md
├── 第21章-Ajax与Comet.md
└── 第5章-引用类型.md
/examples/第25章-新兴的API/test0.txt:
--------------------------------------------------------------------------------
1 | 3y4lriu9z98
--------------------------------------------------------------------------------
/examples/第25章-新兴的API/test1.txt:
--------------------------------------------------------------------------------
1 | kzi2yl61ice
--------------------------------------------------------------------------------
/examples/第25章-新兴的API/test2.txt:
--------------------------------------------------------------------------------
1 | ze4pjsnhhp8
--------------------------------------------------------------------------------
/examples/第25章-新兴的API/test3.txt:
--------------------------------------------------------------------------------
1 | okpjjlka3hh
--------------------------------------------------------------------------------
/examples/第25章-新兴的API/test4.txt:
--------------------------------------------------------------------------------
1 | ge3307kbrwm
--------------------------------------------------------------------------------
/examples/imgs/drawing.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qianlongo/professional-js/HEAD/examples/imgs/drawing.jpeg
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "devDependencies": {
3 | "browser-sync": "^2.18.12",
4 | "gulp": "^3.9.1"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/examples/imgs/async-defer-script.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qianlongo/professional-js/HEAD/examples/imgs/async-defer-script.png
--------------------------------------------------------------------------------
/第2章-在html中使用JavaScript.md:
--------------------------------------------------------------------------------
1 | ## 2.1.2 延迟脚本
2 | 主要理解script标签添加`async` `defer`与正常情况的差别
3 |
4 | 
5 |
--------------------------------------------------------------------------------
/examples/第20章-JSON/testNodeJson.js:
--------------------------------------------------------------------------------
1 | let obj = {
2 | name: 'qianlongo',
3 | sex: 'boy'
4 | }
5 |
6 | let str = '{"name":"qianlongo","sex":"boy"}'
7 |
8 | console.log(JSON.parse(str));
--------------------------------------------------------------------------------
/第20章-Json.md:
--------------------------------------------------------------------------------
1 | 目标
2 |
3 | 1. 理解JSON语法
4 | 2. 解析JSON
5 | 3. 序列化JSON
6 |
7 | ## 前言
8 |
9 | > 为了解决XML过于繁琐、冗长、这个问题,涌现了许多解决方案,JSON就是其中一种,JSON是JavaScript的一个严格的子集,通过一些模式来表示结构化的数据,需要理解的是它是一种数据格式,而不是一种编程语言。虽然具有相同的语法格式,但是JSON并不从属于JavaScript。很多编程语言都有针对JSON的解析器和序列化器。
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.obj
2 | *.dll
3 | *.pdb
4 | *.suo
5 | *.user
6 | .darc
7 | [Bb]in/
8 | [Dd]ebug*/
9 | [Rr]elease*/
10 | node_modules*/
11 | npm-debug.log
12 | packages*/
13 | **/.idea/*
14 | **/.sass-cache
15 | noPopup_nogit.html
16 | .darc
17 | .DS_Store
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | let gulp = require('gulp')
2 | let browserSync = require('browser-sync').create()
3 |
4 | // 静态服务器
5 | gulp.task('browser-sync', function () {
6 | browserSync.init({
7 | server: {
8 | baseDir: "./examples"
9 | }
10 | });
11 | });
12 |
13 | gulp.task('default', ['browser-sync'])
14 |
--------------------------------------------------------------------------------
/examples/第16章-HTML5脚本编程/post-message-iframe.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 |
13 |
14 |
--------------------------------------------------------------------------------
/examples/第25章-新兴的API/genTestFile.js:
--------------------------------------------------------------------------------
1 | let fs = require('fs')
2 |
3 | let prevFileName = 'test'
4 | let genTestFiles = (num) => {
5 | for (let i = 0; i < num; i++) {
6 | let fileName = `${prevFileName}${i}.txt`
7 | fs.unlink(fileName, (err) => {
8 | fs.writeFileSync(fileName, Math.random().toString(36).substr(2))
9 | })
10 | }
11 | }
12 |
13 | genTestFiles(5)
--------------------------------------------------------------------------------
/第17章-错误处理与调试.md:
--------------------------------------------------------------------------------
1 | **本章内容**
2 | . 理解浏览器报告的错误
3 | . 处理错误
4 | . 调试JavaScript代码
5 |
6 | 由于JavaScript本身是动态语言,而且多年来一直没有固定的开发工具,因此人们普遍认为它是一种难以调试的编程语言。脚本出错时,浏览器通常会给出类似于“object expected”(缺少对象)这样的消息,没有上下文信息,让人摸不着头脑。
7 |
8 | ## 17.1 ~ 17.1.5
9 |
10 | > 介绍几款浏览器报告错误的方式以及如何调试。
11 |
12 | ## 17.2 错误处理
13 |
14 | > 错误处理在程序设计中的重要性是毋庸置疑的,任何有影响力的Web程序都需要一套完善的错误处理机制,当然,大多数的佼佼者确实做到了这一点,但通常只有服务端应用程序才能做到如此,实际上,服务端团队往往会在错误处理机制上投入较大的精力,
15 |
--------------------------------------------------------------------------------
/examples/第13章-事件/dom0-event.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 |
11 |
18 |
19 |
--------------------------------------------------------------------------------
/第23章-离线应用与客户端存储.md:
--------------------------------------------------------------------------------
1 | ## 23.3 数据存储
2 |
3 | > 随着 Web应用程序的出现,也产生了对于能够直接在客户端上存储用户信息能力的要求。属于某个特定用户的信息应该存在该用户的机器上,无论是登录信息还是偏好设置或者其他数据。
4 |
5 | > 解决该问题的第一个方案是以cookie的形式出现的,cookie只是在客户端存储数据的其中一种选项。
6 |
7 | ## Cookie
8 |
9 | > HTTP Cookie 通常叫做cookie,最初是在客户端用于存储会话信息的。该标准要求服务器对任意的http请求发送 Set-Cookie HTTP头作为响应的一部分,其中包含会话信息,例如这种服务器响应的头可能如下。
10 |
11 | **cookie以名值对存在,并且名称和值都必须是URL编码的,浏览器会存储这样的会话信息,并在这之后,通过为每个请求添加Cookie HTTP头将信息发送回服务器。**
12 |
13 | 1. 限制
14 |
15 | cookie在性质上是绑定在特定域名下的,当设定了一个cookie之后,再给创建它的域名发送请求时,都会包含这个cookie,这个限制确保了存储在cookie中的信息只能让批准的接受者访问,而无法被其他域访问。
16 |
--------------------------------------------------------------------------------
/examples/第13章-事件/attachEvent.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 |
11 |
21 |
22 |
--------------------------------------------------------------------------------
/examples/第16章-HTML5脚本编程/post-message-parent.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 父窗口
8 |
9 |
10 | 该示例已移动到第5章
11 |
12 |
16 |
17 |
--------------------------------------------------------------------------------
/examples/第13章-事件/event-attrs.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 |
11 |
12 |
24 |
25 |
--------------------------------------------------------------------------------
/第8章-BOM.md:
--------------------------------------------------------------------------------
1 | 本章内容
2 | 1. 理解window对象--BOM的核心
3 | 2. 控制窗口、框架和弹出窗口
4 | 3. 利用location对象的页面信息
5 | 4. 使用navigator对象了解浏览器
6 |
7 | ## 8.1 window对象
8 |
9 | > BOM的核心对象是window,它表示浏览器的一个实例,在浏览器中,window对象有双重角色,它既是通过JavaScript访问浏览器窗口的一个接口,也是ECMAScript规范的Global对象,这意味着在网页中定义任何一个对象,变量或者函数,都以window作为Global对象,因此有权访问parseInt等方法
10 |
11 | ## 8.1.1 全局作用域
12 |
13 | > 所有在全局作用域中声明的变量、函数都会变成window对象的属性和方法。
14 |
15 | ``` javascript
16 |
17 | var age = 29
18 |
19 | function sayAge () {
20 | alert(this.age)
21 | }
22 |
23 | alert(window.age)
24 | sayAge()
25 | window.sayAge()
26 |
27 | ```
28 |
29 | age和sayAge都被自动归在了window对象名下,所以可以通过window.age和window.sayAge访问
30 |
31 | **非常重要**
32 |
33 | 定义全局变量与在window对象上直接定义属性的差别是:全局变量不能通过delete操作符删除,而直接在window对象上的定义的属性可以。
--------------------------------------------------------------------------------
/examples/第5章-引用类型/iframe父窗口.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 在iframe中判断是否为数组父窗口
8 |
9 |
10 |
11 |
19 |
20 |
--------------------------------------------------------------------------------
/examples/第14章-表单脚本/form.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 表单字段
9 |
10 |
11 |
12 |
20 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/examples/第13章-事件/dom2-event2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 |
11 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/第5章-引用类型/iframe子窗口.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 在iframe中判断是否为数组子窗口
8 |
15 |
16 |
17 |
18 |
27 |
28 |
--------------------------------------------------------------------------------
/examples/第15章-canvas/canvas2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | canvas基本使用
9 |
14 |
15 |
16 |
17 |
18 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/examples/第15章-canvas/canvas3.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | canvas基本使用
9 |
14 |
15 |
16 |
17 |
18 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/examples/第15章-canvas/canvas1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | canvas基本使用
9 |
14 |
15 |
16 |
17 |
18 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/第13章-事件/dom2-event.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 |
11 |
28 |
29 |
--------------------------------------------------------------------------------
/examples/第13章-事件/event.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
19 |
20 |
21 |
22 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/第13章-事件/event-fn.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
15 |
16 |
17 |
23 | hello world
24 |
25 |
38 |
39 |
--------------------------------------------------------------------------------
/examples/第15章-canvas/canvas5.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | canvas基本使用
9 |
14 |
15 |
16 |
17 |
18 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/examples/第14章-表单脚本/paste.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | paste
9 |
10 |
11 |
12 |
13 |
14 |
15 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2017 qianlongo
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/examples/第14章-表单脚本/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | input
9 |
10 |
11 |
12 |
16 |
17 |
18 |
19 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/examples/第15章-canvas/canvas4.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | canvas基本使用
9 |
14 |
15 |
16 |
17 |
18 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/examples/第14章-表单脚本/auto-focus.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 自动切换焦点
9 |
10 |
11 |
12 |
17 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/examples/第21章-Ajax与Comet/测试activeXString.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 |
11 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/examples/第13章-事件/addHandler.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 |
11 |
44 |
45 |
--------------------------------------------------------------------------------
/examples/第14章-表单脚本/button-type.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 能够提交表单的类型
9 |
10 |
11 |
12 |
21 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/第16章-HTML5脚本编程.md:
--------------------------------------------------------------------------------
1 | 本章内容
2 | -使用跨文档消息传递
3 | -拖放API
4 | -音频与视频
5 |
6 | ## 16.1 跨文档消息传递
7 |
8 | > 跨文档消息传送(cross-document-messaging),有时候简称为XDM,指的是在来自不同域的页面间传递消息。例如www.wrox.com域中的页面与位于一个内嵌框架中的p2p.wrox.com域中的页面通信。
9 |
10 | XDM的核心是postMessage方法,在HTML5中除了XDM部分之外的其他部分也会提到这个方法名,但都是为了同一个目的:**向另一个地方传递数据**,对于XDM而言,“另一个地方”指的是包含在当前页面中的