// 獲取class <script type="text/javascript"> function getByClass(oParent,sClass){ var aEle=oParent.getElementsByTagName("*"); var aResult=[]; for(var i=0,tt=aEle.length;i=0){ var arr_class=aEle[i].className.split(" "); for(var j=0,len=arr_class.length;j對於上面的代碼,我們可以使用“HTML在線編輯器”進行測試一下。
2.獲取元素樣式// 獲取樣式 function getStyle(obj,name){ if(obj.currentStyle){ return obj.currentStyle[name]; } else{ return getComputedStyle(obj,false)[name]; } }3.阻止事件冒泡// 阻止事件冒泡 function stopBubble(e){ if(e && e.stopPropagation){ e.stopPropagation(); } else{ window.event.cancelBubble=true; } return false; }4.全屏模式// 進入全屏 function fullScreen() { var el = document.documentElement; var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen; if (typeof rfs != "undefined" && rfs) { rfs.call(el); }else if(typeof window.ActiveXObject != "undefined") { // for Internet Explorer var wscript = new ActiveXObject("WScript.Shell"); if(wscript != null) { wscript.SendKeys("{F11}"); } } } // 退出全屏 function exitFullScreen() { var el = document, cfs = el.cancelFullScreen || el.webkitCancelFullScreen || el.mozCancelFullScreen || el.exitFullScreen, wscript; if (typeof cfs != "undefined" && cfs) { cfs.call(el); return; } if (typeof window.ActiveXObject != "undefined") { wscript = new ActiveXObject("WScript.Shell"); if (wscript != null) { wscript.SendKeys("{F11}"); } } }本文來源:(http://www.w3cfuns.com/blog-5448541-5406889.html)