...

View Full Version : Problems validating JS code



EfficientEnergy
07-04-2011, 03:50 PM
We are trying to validate a piece of code on our HTML pages and get the following message - "The text content of element script was not in the required format: Expected space, tab, newline, or slash but found < instead."

The code is used to set up the Facebook tags in JavaScript, and does work by itself. However, we're trying to get it to work through validation on http://validator.w3.org



<script src="SiteTools.js">
//<![CDATA[
<!--
FacebookSetup('CABLED Project first 6 months', 'images/angela-imiev.jpg');
//-->
//]]>
</script>


Thanks

Stooshie
07-04-2011, 05:39 PM
I suspect you will need to import the external script separately from the call to the function.


<script type="text/javascript" src="SiteTools.js"></script>
<script type="text/javascript">
//<![CDATA[
<!--
FacebookSetup('CABLED Project first 6 months', 'images/angela-imiev.jpg');
//-->
//]]>
</script>

Also, I'm not entirely sure you need the CDATA stuff either. That's for really old browsers which few people use these days.

EfficientEnergy
07-04-2011, 05:57 PM
Thank you for your prompt response.

I have copied the code and it now passes the validation. :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum