GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing www.tutorialspoint.com — HTML - DOM Document normalizeDocument() Method
Selected Reading
HTML - DOM Document normalizeDocument() MethodHTML DOM document normalizeDocument() method normalize an entire HTML document unlike normalize() method whose scope was limited to node and it's descendants. It removes empty nodes and merges all adjacent nodes in document. This method is deprecated. Instead of normalizeDocument(), we can use normalize() method. Syntaxdocument.normalizeDocument(); ParameterThis method does not take any parameter. Return ValueThis method does not have a return value. Example of HTML DOM Document 'normalizeDocument()' MethodThe normalizeDocument() method is no longer in use. The following example illustrates it's alternative option which is normalize() method. <!DOCTYPE html>
<html lang="en">
<head>
<title>
HTML DOM Document normalizeDocument() Method
</title>
</head>
<body>
<form>
<fieldset>
<legend>HTML-DOM-normalize()</legend>
<input type="text" id="textSelect" placeholder="type here...">
<input type="button" onclick="makeTextNode()" value="Create Text Node">
<input type="button" onclick="normalizeDocument()" value="Normalize">
<div id="appendedNodes">All Text Nodes: </div>
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
let divDisplay = document.getElementById("divDisplay");
let textSelect = document.getElementById("textSelect");
let appendedNodesDiv = document.getElementById("appendedNodes");
divDisplay.textContent = 'Total Text Nodes: '
+ appendedNodesDiv.childNodes.length;
function makeTextNode() {
let textNode = document.createTextNode(textSelect.value);
appendedNodesDiv.appendChild(textNode);
if (textSelect.value === '')
divDisplay.textContent = 'Empty Text Node Created';
else
divDisplay.textContent = 'Text Node Created with value: '
+ textSelect.value;
divDisplay.textContent += ', Total Text Nodes: '
+ appendedNodesDiv.childNodes.length;
}
function normalizeDocument() {
appendedNodesDiv.normalize();
divDisplay.textContent = 'Total Text Nodes: '
+ appendedNodesDiv.childNodes.length;
}
</script>
</body>
</html>
Supported Browsers
html_dom.htm Advertisements
| ||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |