"The text content of element script was not in the required format: Expected space, tab, newline, or slash but found { instead."
Asked Answered
S

2

8

My HTML is almost HTML5-compliant according to the W3C Validator, only one error is remaining: the Javascript code to configure the Google Plus buttons.

Whether I add CDATA or not, the error "The text content of element script was not in the required format: Expected space, tab, newline, or slash but found { instead." is displayed for this line:

<script src="http://apis.google.com/js/plusone.js" type="text/javascript">
   {"lang":"en","parsetags":"explicit"}
</script>
Skive answered 18/1, 2013 at 22:27 Comment(1)
Looks like your trying to pass an undefined object.Apply
J
3

The error message is correct. A script tag that has its src attribute set can only contain documentation: whitespace and comments (/* ... */ or //...).

If you just want to avoid the error, you could try creating the script tag with js, as in the asynchronous load example. This doesn't make it valid but at least the initially served html will be without errors and validators won't complain.

Jennefer answered 18/1, 2013 at 22:39 Comment(0)
V
2

...I sorely doubt you're going to win the validation-war, here.

If you've got a client/boss that is obsessed over validating (rather than being solid code -- because you can totally have flimsy, flaky, valid code), then you can tell them to drop g+, completely.

But Google is using that script tag to load its file, that file is finding the last script tag that loaded, and then using the inner-text for configuration of the program.

Is it completely valid syntax? Not really, no.

Perhaps they might consider trying to work within JS-comments, but really, Google will change this stuff frequently, as they take over the world and evolve web-programming (angular.js is craaazy).

While they aren't perfect, I'd suspect that their code is more solid than just "W3C validator-approved" code.

Vida answered 18/1, 2013 at 22:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.