Theia installation has been updated - September 10, 2011
« Feb. 2012
S M T W T F S
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28        
Theia
Surely XHTML compliance can't be this stupid « home
icon
posted on 14:00 - 22 May 2010 | posted by Lev
last modified on 12:10 - 11 June 2010 | last modified by Lev
I posted this a while ago on daniweb.com, but have yet to receive any response, despite quite a few folks looking over it. >_<
 
I'm quite impatient with this matter at the moment since I wanted to clean up as much markup as possible today.
 
Here is the scenario I've encountered, to which I'm hoping one of you can provide more information on dealing with:
 
Howdy, First off, I should say that I am jumping on posting this issue much quicker than I normally would - but I'm not really in a patient mood now, and I'm far from being a fan of anything the W3 has done. Anyhow, I am in the process of going through a CMS I've built the past decade and cleaning up its markup so it validates (XHTML Strict). I've run into a little hitch and was wondering if there is a simple solution, or if this is another one of the many restrictions XHTML seems to impose. I understand the whole concept of encoding ampersands - that isn't news to me. My problems lies within JavaScript which is directly placed within the XHTML markup, and doesn't reside in a JavaScript specific file. For example, here is some JavaScript residing within the markup (which I understand to be valid):
XHTML CODE
<script type='text/javascript'>initializeRefresh('ajaxdata.php?type=my_status&u=x&mode=x&showmore=x', 15,'MyStatusMessagePane');</script>
... there I have NOT encoded the ampersands, because as context would dictate, ampersands shouldn't be encoded when in a JavaScript context - correct? Well, the validator throws a fit over it and spits out many errors and warnings over this usage, despite being allowed to hold JavaScript within your markup. So if I change the code to look more like:
XHTML CODE
<script type='text/javascript'>initializeRefresh('ajaxdata.php?type=my_status&amp;u=x&amp;mode=x&amp;showmore=x', 15,'MyStatusMessagePane');</script>
... the validator DOESN'T complain, but the JavaScript code is broken, as the incorrect URL is parsed and loaded. Obviously, I know I could just go into the JavaScript function and replace encoded ampersands with the character itself, but this isn't a solution in my opinion, because it only hides the problem and doesn't address the cause. This same situation occurs in a more common use of JavaScript like so:
XHTML CODE
<span onclick="window.location.href='http://example.com/page.php?id=x&somethig=x';">blah</span>
That code would fail validation, but function properly; yet if you encode the ampersand, it will validate, but won't work! So, what's up here? I'll either slap myself for missing something so silly, or I'll add more fuel to my already roaring fire against W3. >_< Surely there has got to be a practical approach here - to appease both ends - that I've just overlooked or haven't been aware of. I appreciate any information any of you guys and gals may have! Thanks for your time.
 
tags
post reply
tory burch
quote
posted by: guest 118.250.11.169 · date: 9:32 - 12 December 2011
 <a href=http://www.readshoes.com/flats.html>tory burch flats</a> recognize and the plane should be ready for flight tests soon For some people this is the most desirable Omega Speedmaster watch ever given its connection with the classic look and all the updated modern features The dial is very well laid out with the addition of the GMT hand being barely intrusive An excellent flight watch and a stellar addition to the Speedmaster watch lineup Ariel Adams publishes the popular luxury watch review site aBlogtoRead More about Omega Omega Watches Omega News Omega Blogs  <a href=http://www.readshoes.com/sandals-52137-popular.html>suede ballet</a>  <a href=http://www.readshoes.com/sandals-668-popular.html>christian louboutin website</a>  <a href=http://www.readshoes.com/short-boots-CLD022-popular.html>christian louboutins on sale</a>  <a href=http://www.readshoes.com/tall-boots.html>christian louboutin tall boots</a>  Despite the recent furor over Olympic swimming sensation Michael Phelps whose photo with a large marijuana bong at a North Carolina party has created considerable media attention far removed from his athletic accomplishments Swiss watchmaker Omega will stand by its champion "The story is about the private life of Michael Phelps Omega  <a href=http://www.readshoes.com/fashion-collection.html>red bottom shoes</a>
 
Talasan
quote
posted by: guest 66.68.127.113 · date: 0:04 - 01 July 2010
I just want to say -- lawl. W3 validation is, well, a joke. I'm valid as long as you ignore a hundred or so warnings of border-radius, and XHTML5 removed the 'alt' tag? What? -_-;;
untitled
quote
posted by: Lev · date: 20:58 - 22 May 2010
lev
I figured it out eventually - I told you I posted this a bit prematurely! :P

I thought I'd follow up with the solution though in case someone else stumbles on this thread and needs to know what you gotta do.

From a lot of the threads I read about this, most give the typical easy solutions that aren't thought through properly (like "der, put all the code in an external javascript"), so it was hard to find someone who actually knew the real fix:

CDATA!

I've seen "CDATA" appear a few times before but never really knew what it was used for in detail. It turns out, it is used for things like this:

XHTML CODE
<script type='text/javascript'><![CDATA[ initializeRefresh('ajaxdata.php?type=my_status&u=x&mode=x&showmore=x', 15,'MyStatusMessagePane'); ]]></script>


Using this allowed the autorefresh mechanism work again AND it checked out as validated. I have yet to test its use INSIDE another tag like in an "onclick" - so, I can't vouch for if that works (though I did notice that those URLs are working in JavaScript fine even with encoded ampersands).
"Be the change you want to see in the world." - Gandhi
apprentice » 6852 AP » total items: 553 / total posts: 26 » 0.143 / 1.143
Bookmark item @
bookmarkbookmarkbookmarkbookmarkbookmark