W3 Validator bookmarklet
by BenV on Dec.14, 2010, under Software
After messing around with JQuery and friends for quite a while at work and sometimes even for hobby stuff more and more pages turn into the AJAX jungle.
Fine for the user, but there’s one little thing that always annoys me: it becomes very hard to make sure you’re still creating valid (x)html.
Especially when you start using dynamic tabs!
Opera has this nice feature that when you hit CTRL-ALT-SHIFT-u it will upload your current webpage to the W3 Validator. (w3, w3c… what’s up with that…). However, when AJAX molests the entire page (and I’m not talking about soccer fans ;))… or worse, the entire page is loaded through AJAX this method of validation falls flat on its face. Don’t ask me why opera is so stupid, but it will upload the original html, and not the AJAX molested version. An option would be nice there.
So today I was fed up with html errors and made myself a nice little bookmarklet to validate your page. With verbose output. And stuff.
This is the current version, it will probably get shorter / better soon.
(function(){var h=document;var b=h.doctype;var e="\n';var g=h.documentElement.outerHTML;var f="http://validator.w3.org/check";var i={prefill_doctype:"html401",prefill:0,doctype:"inline",group:0,ss:1,st:1,outline:1,verbose:1,fragment:e+g};var a=h.createElement("form");a.setAttribute("method","post");a.setAttribute("target","_blank");a.setAttribute("action",f);for(var j in i){var c=h.createElement("input");c.setAttribute("type","hidden");c.setAttribute("name",j);c.setAttribute("value",i[j]);a.appendChild(c)}if(navigator.appCodeName=="Mozilla"){h.body.appendChild(a)}a.submit()})();
Or right click here and select “Bookmark Link” to put it in a bookmark.
Or left click it if you want to find out how terribly wordpress fails at it 🙂
* Tested a bit on Opera 11, Firefox might also work.
* Note2: work in progress. Bookmarklet last updated at 14-12-2010.
* Known bugs: Opera seems to post some tags without the closing tags.