how can I validate html produced by ajax (asynchronous dynamic html)?

Z

zzzbla

Hi,

I'm writing an ajax component. The results look different on FireFox
and on Internet Explorer. I'd like to validate the html I'm producing
but if I try to save the file and use tidy and/or the firefox
html-validator extension, I just get the initial html, without the
stuff added to it by my javascript functions...

Anyone has a solution?

Thanks in advance,
R. Green
 
A

Adrienne Boswell

Gazing into my crystal ball I observed (e-mail address removed) writing in
Hi,

I'm writing an ajax component. The results look different on FireFox
and on Internet Explorer. I'd like to validate the html I'm producing
but if I try to save the file and use tidy and/or the firefox
html-validator extension, I just get the initial html, without the
stuff added to it by my javascript functions...

Anyone has a solution?

Thanks in advance,
R. Green

Sure, Opera and Firefox both have developer toolbars/extensions that will
allow you to send rendered markup to the validator.
 
Z

zzzbla

Hi Adrienne,

Thanks for your quick reply.

Can you name such Firefox extensions? I've been browsing through the
dev section and couldn't find anything helpful...

Thanks,
R. Green
 
T

Toby Inkster

zzzbla said:
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...
 
Z

zzzbla

Hi,

Thanks for all of your replies.

I finally found a firefox extension that saves the rendered html called
savegenpage ( https://addons.mozilla.org/firefox/2262/ ) - I just save
the HTML, reload it and then check it with the html validator extension
(found at https://addons.mozilla.org/firefox/60/ as Adrienne
mentioned).


My code is flawless in regard to the html, and the css is valid as
well; However - it still shows differently in IE and Firefox!

I wrote an ajax tree component and I use spans inside spans (with a css
margin defined for the children) - in Firefox they show exactly as
you'd think. In IE however, there's an occasional "extra" line break (I
don't have any line breaks at all) - I couldn't find a pattern when
they show and when they don't...

Cheers,
R. Green
 
N

NETAMO Systems

Hello, you can see generated javascript source with the tracer tool

http://www.netamo.com/tracer

It processes the page as the browser does, and traces every function.
Check it.
We are developing it and it's still beta, so we appreciate feedback. It
has some limitations although we are improving it to trace AJAX apps
correctly. Thanks.



(e-mail address removed) ha escrito:
 
Z

zzzbla

Hi,

I checked your tracer. It's nice but since it can't async java it's not
too useful for my purpose. Also, the fact that its a web app and it
can't access my intranet web renders it unuseful... the firefox
extensions work like a charm...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top