amin7b5 Posted October 22, 2008 Share Posted October 22, 2008 I'm really struggling to get a piece of script to validate in xhtml 1.0. The code is the following: <script type="text/javascript">window.addEvent('domready', function() { new YOOtooltip('yoo-tooltip-1', '<img src="images/latest_work/aos.jpg" alt="Alt Text" /><p>Text goes here</p>', { mode: 'cursor', display: 'block', width: 315, style: 'default', sticky: 0 }); });</script> This doesn't validate because of the html code within the script tag, however if I replace the '<' and '>' with < and > it will validate but break the script! My javascript knowledge is limited and this is a third party tool tip script. Thanks in advance for any advice on how to get this to validate! Quote Link to comment https://forums.phpfreaks.com/topic/129633-solved-getting-to-validate/ Share on other sites More sharing options...
DarkWater Posted October 22, 2008 Share Posted October 22, 2008 Add <!-- and --> around the code inside the script. <script type="text/javascript"><!--window.addEvent('domready', function() { new YOOtooltip('yoo-tooltip-1', '<img src="images/latest_work/aos.jpg" alt="Alt Text" /><p>Text goes here</p>', { mode: 'cursor', display: 'block', width: 315, style: 'default', sticky: 0 }); });--></script> Quote Link to comment https://forums.phpfreaks.com/topic/129633-solved-getting-to-validate/#findComment-672222 Share on other sites More sharing options...
amin7b5 Posted October 22, 2008 Author Share Posted October 22, 2008 I surely learn something new every day! Thanks, that was the answer. Quote Link to comment https://forums.phpfreaks.com/topic/129633-solved-getting-to-validate/#findComment-672251 Share on other sites More sharing options...
DarkWater Posted October 22, 2008 Share Posted October 22, 2008 Just to let you know, this is quite customary for Javascript code to use in order to prevent older browsers that don't understand Javascript (I'm talking REALLY old browsers) from just outputting all of the JS. Oh, and by the way, since that fixed it, you should really use: <script type="text/javascript"> <![CDATA[ SCRIPT HERE ]]> </script> That's the right way to do it, I just wanted to see if commenting would fix your problem. Quote Link to comment https://forums.phpfreaks.com/topic/129633-solved-getting-to-validate/#findComment-672256 Share on other sites More sharing options...
amin7b5 Posted October 23, 2008 Author Share Posted October 23, 2008 When I change the comments to <![CDATA[ as recommended, the script breaks. From what I've been reading, this may be due to the fact that the page is serving in text/html and <![CDATA[ will only work if it's serving in application/xhtml+xml. I'm unsure how to change this. ??? Quote Link to comment https://forums.phpfreaks.com/topic/129633-solved-getting-to-validate/#findComment-672352 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.