標籤:lock append ajax ddl body hidden child 沒有 parent
/*漸進增強平穩退化網頁 結構層(structural layer): HTML 展示層(presentation layer): CSS <link rel="stylesheet" href="style.css" media="screen"/> 行為層(behavior layer): JavaScript <script src="scripts.js"></script> 1、使用有意義的標記來構建頁面的結構; 2、把表現性的資訊都分離到CSS樣式表中; 3、負責任地使用不唐突的JavaScript來應用行為增強,同時確保平穩退化。CSS Or JavaScript1、這個問題最簡單的解決方案是什麼;2、哪種解決方案會得到更多的瀏覽器的支援;3、如果想改變某個元素的呈現效果,使用CSS;如果想改變某個元素的行為,使用DOM;如果你想根據某個元素的行為去改變它的呈現效果,請運用你的智慧,在這個問題上沒有放之四海而皆準的答案;node nodeName, nodeType, nodeValue, childNodes, firstChild, lastChild, parentNode, nextSibling, previousSibling, getAttribute(), setAttribute(), appendChild(), insertBefore(), onclick, onkeypress, onmouseover, onmouseout,window open, onload, document DOM getElementById(), getElementsByTagName(), getElementsByClassName(), createElement(), createTextNode(), HTML-DOM innerHTML, body, className, form, write(), CSS-DOM style(fontWeight, fontSize, backgroundColor, ), HTML a: href, accesskey, abbr: title, blockquote: cite, dl: dt: dd: sup: 文件類型 html5 <!DOCTYPE html> html 4.01 嚴格型 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">CSS overflow(visible, hidden, scroll, auto),ajax (Hijax: 漸進增強(progressive enhancement)地使用ajax) XMLHttpRequest readyState(0:未初始化;1:正在載入;2:載入完畢;3:正在互動;4:完成。), responseText, responseXML, status(0, 200, 404, 500...), statusText, open(), send(), onreadystatechange,Math ceil(), floor(), round(),資源HTML5規範 https://www.w3c.org/TR/html5Modernizr 特性檢測 http://www.modernizr.com<canvas>元素規範 http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html<video>元素規範 http://www.whatwg.org/spec/web-apps/current-work/multipage/video.html#videolocalStorage/seseeionStorage 用戶端本機存放區 http://dev.w3.org/html5/webstorage(https://html.spec.whatwg.org/multipage/webstorage.html)WebSocket 與伺服器端雙向通訊 httP://dev.w3.org/html5/websockets/標準化的拖放實現 http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dnd瀏覽器地理位置服務 http://www.w3.org/TR/geolocation-API/W3C HTML5 Working Draft http://www.w3.org/TR/html5WHATWG HTML5 http://www.whatwg.org/spec/web-apps/current-workHTML5互動示範 http://html5demos.com/HTML5相關PPT、代碼、樣本及教程 http://www.html5rocks.com/*///綁定在頁面載入完成後需要執行的函數function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload !== ‘function‘) { window.onload = func; } else { window.onload = function() { oldonload(); func(); } }}//在指定節點之後新增一個節點function insertAfter(newElement, targetElement) { var parent = targetElement.parentNode; if (parent.lastChild === targetElement) { parent.appendChild(newElement); } else { parent.insertBefore(newElement, targetElement.nextSibling); }}//產生ajax請求對象function getHttpObject() { if (typeof XMLHttpRequest === ‘undefined‘) { XMLHttpRequest = function() { try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) { } try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (e) { } try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { } return false; } } return new XMLHttpRequest();}//進行ajax請求的一般步驟function getNewContent() { var request = getHttpObject(); if (request) { request.open(‘GET‘, ‘example.txt‘, true); request.onreadystatechange = function() { if (request.readyState === 4) { alert(request.responseText); } } request.send(null); } else { alert(‘Sorry your browser doesn\‘t support XMLHttpRequest‘); }}//擷取指定節點的下一個元素節點function getNextElement(node) { if (node.nodeType === 1) { return node; } if (node.nextSibling) { return getNextElement(node.nextSibling); } return null;}//給指定元素添加class屬性function addClass(element, value) { if (!element.className) { element.className = value; //element.setAttribute(‘class‘, value); } else { var newClassName = element.className; newClassName += ‘ ‘ + value; element.className = newClassName; }}//給指定tag的nextSibling添加classfunction styleElementSiblings(tag, theclass) { if (!document.getElementsByTagName) return false; var elems = document.getElementsByTagName(tag); var elem; for (var i = 0; i < elems.length; i++) { elem = getNextElement(elems[i].nextSibling); addClass(elem, theclass); }}//表格行的顏色奇偶交錯function stripeTables() { if (!document.getElementsByTagName) return false; var tables = document.getElementsByTagName(‘table‘); var odd; var rows; for (var i = 0; i < tables.length; i++) { odd = false; rows = tables[i].getElementsByTagName(‘tr‘); for (var j = 0; j < rows.length; j++) { if (odd) { //rows[j].style.backgroundColor = ‘#ffc‘; addClass(rows[i], ‘odd‘); odd = false; } else { odd = true; } } }}//滑鼠懸浮某一行時高亮function highlightRows() { if (!document.getElementsByTagName) return false; var rows = document.getElementsByTagName(‘tr‘); for (var i = 0; i < rows.length; i++) { rows[i].onmouseover = function() { this.style.fontWeight = ‘bold‘; } rows[i].onmouseout = function() { this.style.fontWeight = ‘normal‘; } }}
JavaScript -- JavaScript DOM 編程藝術(第2版)