You are here: Re: how can I validate html produced by ajax (asynchronous dynamic html)? « HTML « IT news, forums, messages
Re: how can I validate html produced by ajax (asynchronous dynamic html)?

Posted by Toby Inkster on 05/11/06 10:56

zzzbla wrote:

> I just get the initial html, without the stuff added to it by my
> javascript functions...

Aha -- there's the rub. If your document contains:

<script type="text/javascript">
document.write('<b><i>Foo<\/b><\/i>');
</script>

it will validate because the validator doesn't (and shouldn't) execute
Javascript. But ensuring that the code spat out by the Javascript is valid
is still important, because the browsers still have to render it, right?!

The solution is, once your AJAX has executed, to peek at
document.body.innerHTML using Javascript and then validate whatever's in
there.

Here's a method to do that:

1. Get Opera 9.0 Beta: http://www.opera.com/
2. Get the W3-dev Menu 2.91: http://tobyinkster.co.uk/opera
3. Visit your page and allow the scripts to run.
4. In Opera go to "W3-dev" > "Generated Source" in the menu.
5. From the Generated source, copy and paste everything from "<BODY>" to
"</BODY>" into a text editor.
6. At the end add "</HTML>" and at the start add a DOCTYPE, followed by
"<HTML><HEAD><TITLE>Foo</TITLE></HEAD>".
7. Save the resulting file and upload it to the validator.

I wonder if that can be made into one step? Hmmm...

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация