View Full Version : can't get my webpage validated due to javascript

09-22-2011, 02:34 AM
I'm trying getting one of my webpage XHTML 1.0 Strict.

There is only one error left, namely:

document type does not allow element "br" here

at this line:

container.innerHTML = result.translation.replace(/mdw/g, '<br />');

Obviously this is part of my javascript coding, but it's where the validation goes wrong.

I can't put the javascript in an external file since several javascript variables are getting filled by php.

I've tried several options, but I ain't a javascript expert.. so perhaps someone can help me out.

09-22-2011, 02:57 AM
did you try with

container.innerHTML = result.translation.replace(/mdw/g, '<br>'); ?

09-22-2011, 03:01 AM
Yes I tried that, the validation goes wrong on the < > characters.

09-22-2011, 03:31 AM

09-22-2011, 04:47 AM
You need to use cdata

rnd me
09-22-2011, 05:00 PM
use external scripts with strict. or don't use strict; it's not as good at js as transitional anyway...

09-22-2011, 05:12 PM
Aerospace is correct, enclose your javascript code in CDATA tags.

<script type="text/javascript">
// your javascript code