1. If the Window object is a regular HTML page,
TOPis self var top = document.getElementById (' top '); Top.innerhtml//undefined 2,
ev.stoppropagation ();//
Block Event bubbling
function (EV) { // organization event bubbling function() { for (var i = 0; i < ali.length; i++) { var img = ali[i].getelementsbytagname (' img ') [0]; = ' Images/darkstar.png '; }};
3, var ali_right = aul[1].getelementsbytagname (' li '); Ali_right instanceof Array//false--it is an object, but not an array, so you cannot use the array concatenation method concat
object Conversion and splicing of an arrayThe way: For loop
varAUl = document.getElementsByTagName (' ul ');varAli_left = aul[0].getelementsbytagname (' li ');varAli_right = aul[1].getelementsbytagname (' li ');varToconcatarray =function(left, right) {varArrli = []; for(vari = 0; i < left.length; i++) {Arrli.push (left[i]); } for(varj = 0; J < Right.length; J + +) {Arrli.push (right[j]); } returnArrli;};varALi =Toconcatarray (Ali_left, ali_right);//However, if you do not need to exclude other Li in a block, only the target Li, you can directly://var aLi = document.getelementsbytagname (' li ');
4.
get viewport size and document size
/*viewport size, some mobile device browser to innerwidth compatibility is not good, need to *document.documentelement.clientwidth or document.body.clientWidth * To be compatible (Document.documentElement.clientWidth is not supported in promiscuous mode). * How to use: GetViewport (). width; */functionGetViewport () {if(Document.compatmode = = "Backcompat") {//browser sniffing, promiscuous mode return{width:document.body.clientWidth, height:document.body.clientHeight}; } Else { return{width:document.documentElement.clientWidth, height:document.documentElement.clientHeight }; }}//get the size of the document (the difference and the viewport), the same way you would get the viewport size abovefunctionGetdocumentport () {if(Document.compatmode = = "Backcompat") { return{width:document.body.scrollWidth, height:document.body.scrollHeight}; } Else { return{Width:Math.max (document.documentElement.scrollWidth, Document.documentElement.clientWidth), Height:Math.max (Document.documentElement.scrollHeight, Document.documentElement.clientHeight) }}}
clientheight: Content height +padding height, the Innerheight () method in jquery returns this height.
offsetheight: Content height +padding height + border width, the Outerheight () method in jquery returns this height
Note: Use document.getElementById (' bottom '). style. [Height | width]Dom.style.width this way
only the inline properties can be taken.Instead of CSS properties
JavaScript Basics Learning-Piecemeal