--- title: > On-the-fly page validation date: 2004-06-01 18:15 status: published tags: validation, JavaScript, The Twaddle, XHTML, the Web ---
I wonder if this is possible. I've been dabbling with JavaScript a little recently, in order to produce The Twaddle's Expletatron and this seems like something that should be possible with JS:
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.
What's this got to do with validation? Well say the remote page was http://validator.w3.org/check/referer and the given id was result
. Then, if the returned variable is valid
(i.e. the class of that element is valid
) you've got a valid page; if the returned variable isn't valid
you haven't.
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.
I know it's possible to refer to an element by its id; I know it's possible to get the content 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.
It'd be nice though.