<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title>JavaScript · Grey Nicholson</title><id>https://gkn.me.uk/entries/javascript</id><link href="https://gkn.me.uk/entries/javascript" rel="alternate"/><link href="https://gkn.me.uk/entries/javascript/feed" rel="self"/><author><name>Grey Nicholson</name></author><icon>https://gkn.me.uk/style/icon.svg</icon><updated>2025-10-21T12:11:00+00:00</updated>
<entry><title>On-the-fly page validation</title><id>https://gkn.me.uk/weblog034</id><link href="https://gkn.me.uk/weblog034" rel="alternate" type="text/html"/><published>2004-06-01T18:15:00+00:00</published><updated>2004-06-01T18:15:00+00:00</updated><content type="html">
&lt;p&gt;
I wonder if this is possible. I&#x27;ve been dabbling with JavaScript a little recently, in order to produce The Twaddle&#x27;s &lt;a href=&quot;http://purl.org/thetwaddle/expletatron&quot;&gt;Expletatron&lt;/a&gt; and this seems like something that should be possible with JS:
&lt;/p&gt;
&lt;p&gt;
I want a script that can load up a given remote page (internally - I don&#x27;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.
&lt;/p&gt;
&lt;p&gt;
What&#x27;s this got to do with validation? Well say the remote page was &lt;a href=&quot;http://validator.w3.org/check/referer&quot; title=&quot;The W3C Validator&#x27;s results for the referring page&quot;&gt;http://validator.w3.org/check/referer&lt;/a&gt; and the given id was &lt;samp&gt;result&lt;/samp&gt;. Then, if the returned variable is &lt;samp&gt;valid&lt;/samp&gt; (i.e. the class of that element is &lt;samp&gt;valid&lt;/samp&gt;) you&#x27;ve got a valid page; if the returned variable isn&#x27;t &lt;samp&gt;valid&lt;/samp&gt; you haven&#x27;t.
&lt;/p&gt;
&lt;p&gt;
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.
&lt;/p&gt;
&lt;p&gt;
I know it&#x27;s possible to refer to an element by its id; I know it&#x27;s possible to get the &lt;em&gt;content&lt;/em&gt; of that element. I don&#x27;t know if it&#x27;s possible to get an element&#x27;s class, and I&#x27;m guessing it&#x27;s slightly impossible to do all this for another, remote page.
&lt;/p&gt;
&lt;p&gt;
It&#x27;d be nice though.
&lt;/p&gt;</content></entry>
</feed>