Page 1 of 1

delimiting scripts with xhtml

PostPosted: Thu Apr 11, 2013 10:42 am
by RSteinwand
Hi Albert,

I have both a fascination and hate relationship with xhtml.

For some reason, years ago I felt compelled to convert to xhtml strict, but wasn't ready to commit on the xml doc type, instead sticking with text/html. I thought everything was great until you and I discussed document.writes with xhtml and found out my code didn't validate via W3C, even tho CSE had no problem with it.

To make W3C happy, after reviewing this Mozilla dev page, I added comments to my scripts, but CSE doesn't like that.

Code: Select all
<script type="text/javascript">
   <!--
   function SavePrefs(){}
   function LoadPrefs(){if(emulateDesktop){InsertTopLogo();}rndtestimonial(false,true);showfeatdiv();showtradeshows();Copyright();}
   // -->
</script>


I already use external style and scripts, but this is the inline content that varies on each page.

Now I'm tempted to change to a different doc type.

Re: delimiting scripts with xhtml

PostPosted: Thu Apr 11, 2013 10:54 am
by Albert Wiersch
Hi Rick,

That appears to be a 10 year old article. I think the added comments will cause more problems than they solve. I would not use them nowadays, especially in XHTML documents which can cause the script or style to be completely ignored if processed (parsed) by XML rules.

I would recommend moving to HTML5, unless you have specific needs to process your documents as XML, which it doesn't sound like you do.

Because you are already using XHTML, you might also consider polyglot documents which can be served as either HTML5 text/html or XHTML5 (application/xhtml+xml).

More information is here:
http://www.htmlvalidator.com/htmlval/v1 ... l_node.htm

Re: delimiting scripts with xhtml

PostPosted: Thu Apr 11, 2013 12:40 pm
by RSteinwand
I didn't notice the page was that old.

I started converting to html5. Thanks. :D

Re: delimiting scripts with xhtml

PostPosted: Mon Apr 15, 2013 8:15 pm
by RSteinwand
I'm done converting the public side and most of the secure side of our website. It was a little too easy (and disappointing)... I guess I prefer more structured rather than less, but it went well. :mrgreen:

Thanks for the suggestion.

Re: delimiting scripts with xhtml

PostPosted: Mon Apr 15, 2013 8:28 pm
by Albert Wiersch
RSteinwand wrote:I'm done converting the public side and most of the secure side of our website. It was a little too easy (and disappointing)... I guess I prefer more structured rather than less, but it went well. :mrgreen:

Thanks for the suggestion.


Hi Rick,

You can make CSE HTML Validator more strict, like turning on the option to require optional end tags in the Validator Engine Options. It's in the Validator Engine->Tag Options page. There may be other options you might want to turn on as well, like requiring all attribute values to be quoted (in the Validator Engine->Attribute Options page).

Re: delimiting scripts with xhtml

PostPosted: Mon Apr 15, 2013 8:41 pm
by RSteinwand
Hi Albert, my CSE is still strict, but I was disappointed that html5 is so lax. It's easier for me to learn something where there are definite rules.