Files: f20c57f6161c71790d2a002ae9fcaa5cbf30d94b / 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 <q>result</q>. Then, if the returned variable is <q>valid</q> (i.e. the class of that element is <q>valid</q>) you've got a valid page; if the returned variable isn't <q>valid</q> you haven't.
</p>
<p>
So, you could, using JavaScript, whack in a <q>Valid XHTML</q> logo if, and only if, the page is actually valid. If you like, you could throw in an <q>Invalid!</q> 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