02 2011 档案
摘要:没什么技术难度,主要是Array对象的push()和shift()方法的调用。一般的实现方法,即直接分别在id为start和stop的button上添加onclick事件,然后执行相应的函数:html:<div id="test">这里是滚动的文字!</div><p class="btns"><button type="button" id="start">开始</button><button type="button" id=&
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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()
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文