Files: 8e0d7e643c647b11a09fa74cf75bd78b828004c6 / content / weblog034.md
title: "On-the-fly page validation" date: 2004-06-01 18:15 status: published tags: validation, JavaScript, The Twaddle, XHTML, the Web
<p>
I wonder if this is possible. I've been dabbling with JavaScript a little recently, in order to produce The Twaddle's <a href="http://purl.org/thetwaddle/expletatron">Expletatron</a> and this seems like something that should be possible with JS:
</p>
<p>
I want a script that can load up a given remote page (internally - I don't want to display the page, just to extract info from it), look at an element on that page with a given id, and return its class as a variable.
</p>
<p>
What's this got to do with validation? Well say the remote page was <a href="http://validator.w3.org/check/referer" title="The W3C Validator's results for the referring page">http://validator.w3.org/check/referer</a> and the given id was <samp>result</samp>. Then, if the returned variable is <samp>valid</samp> (i.e. the class of that element is <samp>valid</samp>) you've got a valid page; if the returned variable isn't <samp>valid</samp> you haven't.
</p>
<p>
So, you could, using JavaScript, whack in a “Valid XHTML” logo if, and only if, the page is actually valid. If you like, you could throw in an “Invalid!” image if the page is not valid.
</p>
<p>
I know it's possible to refer to an element by its id; I know it's possible to get the <em>content</em> of that element. I don't know if it's possible to get an element's class, and I'm guessing it's slightly impossible to do all this for another, remote page.
</p>
<p>
It'd be nice though.
</p>
Built with git-ssb-web