前言 抓取网页数据时使用HtmlAgilityPack分析,需要通过xpath定位页面元素.如果有个xpath的生成和验证工具就事半功倍了,火狐浏览器插件FirePath配合Firebug就能完美实现. FirePath介绍如下: FirePath is a Firebug extension that adds a development tool to edit, inspect and generate XPath 1.0 expressions, CSS 3 selectors and…
总结this的3个规则: this是调用上下文,上下文被创建或者初始化时才确定 非严格模式:this是全局对象:严格模式:this是undefined 函数调用 a. 以函数形式调用的函数通常不使用this关键字,非严格模式下函数调用模式的this就是全局对象. b. 以方法形式调用的函数的this指的是当前调用方法的对象 c. 以构造函数形式调用的函数的this指的是被构造的对象,具体操作为: i. 创建一个新对象 ii. 将构造函数的作用域赋给新对象(因此构造函数中的this就指向这个新对象…
var data = [ {id:100000, name :"1", pid :0}, {id:100100, name :"1-1", pid :100000, }, {id:100101, name :"1-1-1", pid :100100, }, {id:200000, name :"2", pid :0, }, {id:210000, name :"2-1", pid :200000, }, {…
5)构造函数的用法: 例 3.5.1 <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/></head><script> function Student(name, age) { /* 马克-to-win:later on we can use it in var doc =…
8)arguments 例 3.8.1<head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/></head><script> /* 马克-to-win:when there are n functions with the same function name, only the last one is used…
prototype见上一节,马克-to-win:prototype作用就是给某个类增加一个实例方法. 例 3.6.2 <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/></head><script> /*When the Global object is created, it always has at lea…
6)静态方法和prototype(难) 例 3.6.1 <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/></head><script> /*note that 马克-to-win: static variable's value has nothing to do with instance's varia…
4)Function用法 例 3.4.1 <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/></head><script> /*When the Global object is created, it always has at least the following properties: O…
3)嵌套函数例 3.3.1<head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/></head><script> function outerFun(){ var i = 0; function innerFun(){ document.write(i); …
Firebug记录Javascript日志 你可以使用Firebug来生成日志. 这有助于我们调试web页面并发现页面的错误. 在Firefox浏览器中执行以下代码: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><meta http-equiv="Conte…
内容提纲: 1.XMLHttpRequest 2.GET与POST 3.封装Ajax 发文不易,转载请注明链接出处,谢谢! 2005年Jesse James Garrett发表了一篇文章,标题为:“Ajax:A new Approach to Web Applications”.他在这篇文章里介绍了一种技术,用他的话说,就叫:Ajax,是Asynchronous JavaScript + XML的简写.这种技术能够想服务器请求额外的数据而无须卸载页面(即刷新),会带来更好的用户体验.一时间,席…
原文:How to Learn JavaScript Properly(2014-2-7) 学习时长:6-8周 学习前提:中学水平,无需编程经验 更新(2014-1-7) 在Reddit上创建了一个学习小组 January 2014, “Learn JavaScript” Study Group on Reddit 目录 不要这样学习JavaScript 本课程资源 1-2周(简介,数据类型,表达式和操作符) 3~4周(对象,数组,函数,DOM,jQuery) JavaScript终极编辑器:W…