RMN Posted October 14, 2006 Share Posted October 14, 2006 I have a JavaScript <script> that generates plain text output, and which I want to include in the middle of a paragraph. W3's XHTML validator has no problem with that. However, it tells me the <noscript> block that comes after it cannot be directly inside a <p>. But it validates fine if I enclose it in an <ins> or <del> block.Can anyone explain the logic behind that? The code looks more or less like this: <p>Hello<script type="text/javascript"> <!-- print_user_name(); // --></script><noscript>dear user,</noscript>and welcome to our site.</p> Sure, I can move all the text into the JavaScript function, but what kind of sense does it make to allow a <script> block inside a paragraph but not a <noscript> block...? Is this a bug in the validator?RMN~~~ Link to comment Share on other sites More sharing options...
boen_robot Posted October 15, 2006 Share Posted October 15, 2006 It could be. Try to report it in the mailing list. If it turns out it's not, then what you can do as a workaround is to replace the noscript element with another one (like span for example) and apply a replace of it's text with JS. Link to comment Share on other sites More sharing options...
RMN Posted October 15, 2006 Author Share Posted October 15, 2006 what you can do as a workaround is to replace the noscript element with another one (like span for example) and apply a replace of it's text with JS.Hm... Somehow I think that trying to use JavaScript to edit the contents of a <noscript> element would be a bit pointless. If JS is active, the element won't be shown at all. If JS is not active, then the code that was supposed to modify it would never run. :)I just enclosed it inside an <ins> element (which makes the validator happy) and set the CSS properties of the <ins> to prevent it from actually changing the look of what's inside it.RMN~~~ Link to comment Share on other sites More sharing options...
boen_robot Posted October 15, 2006 Share Posted October 15, 2006 I said replace the noscript element with another one (like span for example)Oh, for crying out loud:<p>Hello<script type="text/javascript"><!--print_user_name();// --></script><span>dear user,</span>and welcome to our site.</p> If you hide the span's content with JS, then this content won't be hidden when JS is off. Link to comment Share on other sites More sharing options...
RMN Posted October 15, 2006 Author Share Posted October 15, 2006 Ok, I thought you meant replace the <noscript> with a <span> using JavaScript (not the other way around) . RMN~~~ Link to comment Share on other sites More sharing options...
RMN Posted October 15, 2006 Author Share Posted October 15, 2006 Apparently the validator is working correctly. The XHTML 1.0 DTD treats <script> and <noscript> in very different ways, and won't allow a <noscript> inside a paragraph, even though it will allow a <script>.The good news is that, in XHTML 1.1, <noscript> can be inside a <p> and doesn't trigger any errors.RMN~~~ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now