摘要: View Code //元素大小var box = document.getElementById("box");alert(box.offsetLeft);//58function getElementLeft(element) {//求element元素在页面上的左偏移量,top相似 var actualLeft = element.offsetLeft; var current = element.offsetParent;//offsetParent属性不一定与parentNode相等,如td的offsetParent为作为其祖先元素的table while(cur 阅读全文
posted @ 2011-02-26 17:02 chemdemo 阅读(295) 评论(0) 推荐(0) 编辑
摘要: View Code //-----------------DOM2 node-----------------//对html元素来说,localName为html,tagName是html,nameSpaceURI是http://www.w3.org/1999/xhtml,prefix是null//对svg来说,localName为svg,tagName是s:svg,nameSpaceURI是http://www.w3.org/2000/svg,prefix是svar svg = document.getElementsByTagName("s:svg");alert(do 阅读全文
posted @ 2011-02-26 17:01 chemdemo 阅读(490) 评论(0) 推荐(0) 编辑
摘要: View Code var leftPos = (typeof window.screenLeft == "number") ? window.screenLeft : window.screenX;var topPos = (typeof window.screenTop == "number") ? window.screenTop : window.screenY;//alert(leftPos + "," + topPos);//alert(top.screenX);window.moveTo(0, 0);window.mov 阅读全文
posted @ 2011-02-26 16:52 chemdemo 阅读(244) 评论(0) 推荐(0) 编辑
摘要: View Code function createComparisionFunction(prototypeName) { return function(object1, object2) { var value1 = object1[prototypeName]; var value2 = object2[prototypeName]; if(value1 < value2) { return -1; } else if(value1 > value2) { return 1; } else { return 0; } }}function createFunctions() 阅读全文
posted @ 2011-02-26 16:51 chemdemo 阅读(186) 评论(0) 推荐(0) 编辑
摘要: View Code //Object类型 //new操作符创建Object实例var person = new Object();person.name = 'chemdemo';person.age = 23; //对象字面量创建对象var person = { name : "chemdemo", age : 23};var person = { "name" : 'chemdemo', 'age' : 23};var person = {};person.name = 'chemdemo 阅读全文
posted @ 2011-02-26 16:48 chemdemo 阅读(230) 评论(0) 推荐(0) 编辑
摘要: View Code //XHR对象的创建//适用于IE7之前的版本function createIeXHR() { if(typeof arguments.callee.activeXString != 'string') { var versions = ['MSXML2.XMLHttp.6.0', 'MSXML2.XMLHttp.3.0', 'MSXML.XMLHttp']; for(var i=0, len=versons.length; i<len; i++) { try { var xhr = new Active 阅读全文
posted @ 2011-02-26 16:36 chemdemo 阅读(332) 评论(0) 推荐(0) 编辑