Return to Snippet

Revision: 43180
at March 18, 2011 15:23 by mecha


Initial Code
var validateLocalMarkup = function() {
	(function() {
		var xhr = new XMLHttpRequest();
		xhr.open('GET', window.location, true);
		xhr.send(null);
		
		xhr.onreadystatechange = function() {
			if (xhr.readyState !== 4) return;
			if (!xhr.status || xhr.status === 200) {
				var source = xhr.responseText;
				var f = document.createElement('form'), i = document.createElement('input');

				f.action = 'http://validator.w3.org/check';
				f.enctype = 'multipart/form-data';
				f.method = 'post';
				f.target = '_blank';

				i.type = 'hidden';
				i.name = 'fragment';
				i.value = source;

				f.appendChild(i);
				document.body.appendChild(f);
				f.submit();
				document.body.removeChild(f);
			}
		};
	})();
};

Initial URL


Initial Description


Initial Title
Validate Local Page Markup in JavaScript

Initial Tags
javascript, validation

Initial Language
JavaScript