摘要: DOM 操作内容 innerText/innerHTMLinnerText属性(firefox不支持,可用 textContent)var div = document.getElementById("itTag");div.innerText/div.textContent 来获取里面的文本,会去除 html标签获取值时用div.innerText = "lin3615" / div.textContent="lin3615"为了兼容,可用下列方法 var obj = document.getElementById("tx 阅读全文
posted @ 2014-04-06 17:05 好记性还真不如烂笔头 阅读(912) 评论(0) 推荐(0) 编辑
摘要: DOM 之 document 查找元素方法 getElementById("idName"); // 始终取得第一个 idName 的元素getElementsByTagName("元素标签名") // 返回是一个集合,可用[索引值]来获取相关指定元素或者通过 item(索引值),如 getElementsByTagName("p")[0] / getElementsByTagName("p").item(1);getElementsByName("name"); // 也就是说元素必须带有 n 阅读全文
posted @ 2014-04-06 16:40 好记性还真不如烂笔头 阅读(1541) 评论(0) 推荐(0) 编辑
摘要: /* avaiHeight // 屏幕的像素高度减去系统部件高度之后的值 var ah = screen.availHeight; alert(ah); */ /* availWidth 屏幕的像素宽度减去系统部件宽度之后的值 var aw = screen.availWidth; alert(aw); *//* // height 屏幕的像素高度 var h = screen.height; alert(h); */ // width 屏幕的像素宽度 var w = screen.width; alert(w);===============================history . 阅读全文
posted @ 2014-04-06 13:48 好记性还真不如烂笔头 阅读(254) 评论(0) 推荐(0) 编辑
摘要: BOM 之 location它提供了与当前窗口中加载的文档有关的信息,还提供一些导航功能。既是 window对象的属性,也是document对象的属性,就是说,window.location 和 document.location 引用的是同一个对象。还可以将 URL 解析为独立的片段,如location.hash: "#contents" //返回 URL 中的 hash;location.host : www.cnblogs.com:80 //返回服务器名称和端口号(如果有)location.hostname: "www.cnblogs.com" / 阅读全文
posted @ 2014-04-06 11:53 好记性还真不如烂笔头 阅读(353) 评论(0) 推荐(0) 编辑
摘要: BOM 之 window 对象 在网页中定义的任何一个对象,变量和函数,都以 window 作为其 Global 对象,因此有权访问别的方法和属性 var age = 26; function sayAge() { alert(this.age); } // alert(window.age); // 26 // sayAge(); // 26 window.sayAge(); // 26在全局作用域中定义了一个变量 age 和 一个函数 sayAge(),它们被自动归在了 window对象名下,于是,可以通过 window.age 访问变量 age,可以通过 window.sayAge(). 阅读全文
posted @ 2014-04-06 10:37 好记性还真不如烂笔头 阅读(200) 评论(0) 推荐(0) 编辑