Is there any parameter/function in JS that tells you if an element was closed with an ending tag? ... for this purpose.
views:
70answers:
2
+9
A:
JS is simply the scripting language that provides access to the DOM of the page. The DOM is preparsed from the page source before you ever get access to it. I am fairly sure that any attempt to access the page source will return the pre-corrected source as determined by the browser during the initial parsing phase.
So in a word, no.
Nathan Ridley
2009-06-01 11:40:50
Pity that browsers don't give you access to such basic validation features.
Jenko
2009-06-01 12:08:13
@Jeremy: IMO, the reason is that a browser is not primarily a developer tool.
Cerebrus
2009-06-01 13:04:42
+2
A:
function getSource() {
var xhr = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
xhr.open('GET', window.location.href, false);
xhr.send(null);
return xhr.responseText;
}
Taking this approach you'd have to parse the HTML yourself - a momentous task.
J-P
2009-06-01 13:37:35