摘要: 加载资源的形式 输入 url 加载 html http://coding.m.imooc.com 加载 html 中的静态资源 `` 加载一个资源的过程 浏览器根据 DNS 服务器得到域名的 IP 地址 向这个 IP 的机器发送 http 请求 服务器收到、处理并返回 http 请求 浏览器得到返回 阅读全文
posted @ 2019-04-08 20:15 木石天涯 阅读(301) 评论(0) 推荐(0) 编辑
摘要: ``` window.addEventListener('load', function () { // 页面的全部资源加载完才会执行,包括图片、视频等 }) document.addEventListener('DOMContentLoaded', function () { // DOM 渲染完即可执行,此时图片、视频还可能没有加载完 }) ``` 阅读全文
posted @ 2019-04-07 21:53 木石天涯 阅读(856) 评论(0) 推荐(0) 编辑
摘要: cookie cookie 本身不是用来做服务器端存储的(计算机领域有很多这种“狗拿耗子”的例子,例如 css 中的 float),它设计是用来在服务器和客户端进行信息传递的,因此我们的每个 http 请求都带着 cookie。但是 cookie 也具备浏览器端存储的能力(例如记住用户名和密码),因 阅读全文
posted @ 2019-04-06 21:19 木石天涯 阅读(147) 评论(0) 推荐(0) 编辑
摘要: ``` ``` 阅读全文
posted @ 2019-04-06 20:45 木石天涯 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 我们设定一种场景,如下代码,一个中包含了若干个,而且还能继续增加。那如何快捷方便的为所有的绑定事件呢? 这里就会用到事件代理,我们要监听的事件,但要把具体的事件绑定到上,然后看事件的触发点,是不是 那我们现在完善一下之前写过的通用事件绑定函数,加上事件代理 然后这样使用 最后,使用代理的优点 使代码 阅读全文
posted @ 2019-04-06 20:07 木石天涯 阅读(398) 评论(0) 推荐(0) 编辑
摘要: 对于以上 html 代码结构,点击p1时候进入激活状态,点击其他任何p都取消激活状态,如何实现? 如果我们在p1 div1 body中都绑定了事件,它是会根据 DOM 的结构,来冒泡从下到上挨个执行的。但是我们使用e.stopPropatation()就可以阻止冒泡。 阅读全文
posted @ 2019-04-06 20:05 木石天涯 阅读(156) 评论(0) 推荐(0) 编辑
摘要: ``` function bindEvent(elem, type, selector, fn) { if (fn == null) { fn = selector selector = null } elem.addEventListener(type, function (e) { var target i... 阅读全文
posted @ 2019-04-06 20:03 木石天涯 阅读(417) 评论(0) 推荐(0) 编辑
摘要: ``` console.log(location.href) console.log(location.protocol) // 'http:' 'https:' console.log(location.pathname) // '/learn/199' console.log(location.search) console.log(location.hash) ``` 阅读全文
posted @ 2019-04-06 16:05 木石天涯 阅读(541) 评论(0) 推荐(0) 编辑
摘要: ``` var ua = navigator.userAgent var isChrome = ua.indexOf('Chrome') console.log(isChrome) ``` 阅读全文
posted @ 2019-04-06 16:03 木石天涯 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 获取 DOM 节点: prototype: DOM 节点就是一个 JS 对象,它符合之前讲述的对象的特征 ———— 可扩展属性 Attribute: property 的获取和修改,是直接改变 JS 对象,而 Attibute 是直接改变 html 的属性。两种有很大的区别 DOM 树操作 + 新增 阅读全文
posted @ 2019-04-06 15:49 木石天涯 阅读(146) 评论(0) 推荐(0) 编辑