---
title: "javascript"
author: "gatusso52"
date: "2009-10-12T02:46:58Z"
tags: ["CSS", "Firefox", "IE", "JavaScript", "prototype"]
slug: "javascript"
draft: false
lastmod: "2009-10-12T04:16:24Z"
id: 485685
url: "https://gatusso52.iteye.com/blog/485685"
---

**1 事件**

**无线程 天然异步**

**两种传递方式：捕获 冒泡**

**三种绑定方法：**

**传统方式 ： a.onclick = function(){}只能冒泡**

**绑定监听（IE）: a.attachEvent('onSumbit',function(){}) 只能冒泡，this指window而非当前元素**

**绑定监听（W3C）：a.addEventListener('submit',fuction(){}.false) fasle表示冒泡 true表示捕获  this指当前元素** 

**2 CSS**

**可见性**

**visibility : visible, hidden （保持空白）**

**display：inline（保持流动性）block（破坏流动性）none（无空白）**

**位置**

**abusolote  fixed  relative  static（只遵循普通流动，top left无效。它是默认，故如果要设置位置 一定要指定一下别 的定位方式）**

**offsetLeft offsetTop  offsetParent（ie与firefox不一样）**

**3语言特性**

**引用**

**函数重载**

**类型检查 if（typeof a=="string"）         object function string number boolean**

**作用域  js的作用域以函数为边 而不是以块！！ 所有全局变量默认作用域为window**

**闭包 内层可以引用外层**

**4对象**

**无类的概念 原型式继承**

**原理 每个类都有一个prototype属性 用它来扩展成新对象**

**公共方法【不能调用私有成员】**

**function A(name){this.name = name}**

**A.prototype.sayhello() = function(){}**

**私有方法**

**fuction A(name){**

  **function sayHello(){]**

**}**

**特权方法【可以调用私有成员】**

**function A（name）{**

  **this.sayHello = fuction(){}**

**}**

**静态方法**

**function A(){}**

**A.sayHello = function(){}**

**var test=function(){**  
**alert("123")**  
**}**  
**等价于**  
**function test(){**  
**alert("123")**  
**}**

**在js最外层写的function可以还可以理解为window对象的一个方法。**

**5DOM**

**全局变量 document HTMLElement**

**定位 body documentElement**

**操作getElementByID getElementsByTag lastChild nextSibling parentNode**

**节点属性** 

**innerTex t返回纯文本 掐去所有node**

**nodeName 返回li 之类的**

**nodeType 返回document。ELEMENT\_TYPE TEXT\_TYPE DOCUMENT\_TYPE**

**nodeValue**

**特性（Attribute）**

**classname 返回css类**

**getAttribute  removeAttribute  setAttribute**

**DOM修改**

**appendChild**

**cloneNOde**

**createElement**

**createElementNS**

**createTextNode**

**insertBefore**

**removeChild**

**replaceChild**