...

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



docock
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.

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

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

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

xelawho
09-22-2011, 03:31 AM
.....

_Aerospace_Eng_
09-22-2011, 04:47 AM
You need to use cdata
Http://javascript.about.com/library/blxhtml.htm

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...

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



<script type="text/javascript">
<![CDATA[
// your javascript code
]]>
</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum