There should be no XHTML validation errors like Error: document type does not allow element "style" here.

<noscript><style type="text/css">form.rating{ display: block; }</style></noscript></body>
CommentFileSizeAuthor
#20 jrating.patch670 bytessmitty
#12 Validation-output.jpg107.06 KBsmitty

Comments

hass’s picture

additional this tag is added independently of a voting box is displayed or not, what makes no sense. only add this code if the voting box is added to the page.

hickory’s picture

Priority: Critical » Normal

It's added by jrating_footer: is there a way to tell whether a rating widget has been added to the page in hook_footer? Could look in the array of files added by drupal_add_js, perhaps...

I can't think of a better way to display the block when javascript is disabled, so it'll have to be invalid XHTML for now.

hass’s picture

i'm sure it is possible - i will try to find a solution next week and provide a patch if found.

For me the current module cannot be used, while i advertise my 20 themes as 100% error and warning free XHTML complicant code and i cannot break with this... no way.

hass’s picture

take a look to fivestar rating, please. they solved this well in the following way:

if (strpos(drupal_get_js(), "jQuery('input.fivestar-submit').hide()") === FALSE) {
  drupal_add_js("jQuery(function(){jQuery('input.fivestar-submit').hide();});", 'inline');
}

So you should change jratings code to display the selectbox everytime and if JS is enabled it will hide... and XHTML code will be valid.

hickory’s picture

I'll give that a try, but I'm not sure whether it'll work fast enough to hide the form before it's displayed...

momper’s picture

hello

is there something new?

thanks and greetings
momper

hickory’s picture

Version: 5.x-1.0 » 5.x-1.x-dev
Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

smitty’s picture

Status: Closed (fixed) » Active

I am running the Version of 2007-Dec-04 ant get se same validation error from http://validator.w3.org/check: document type does not allow element "style" here.

The code in HTML-Page is in the header:

$("head").append("form.rating{display:none}"); if ($.browser.safari){ $("head").find("style:last").append(" ") }

Please help!

hickory’s picture

smitty: do you have a page I can look at with this problem?

smitty’s picture

@hickory: I sent you an e-mail this morning.

smitty’s picture

StatusFileSize
new107.06 KB

I replaced the the jrating.module with the one of the version 2007-Nov-23.
There I do not get a validation error.
So it must have something to do with:

function jrating_footer($main = FALSE){
  drupal_add_js(
  '$("head").append("<style type=\'text/css\'>form.rating{display:none}</style>");
  if ($.browser.safari){ $("head").find("style:last").append(" ") }',
  'inline', 'header');
  // have to append the contents otherwise safari doesn't recognise it

putting

<script type="text/javascript">$("head").append("<style type='text/css'>form.rating{display:none}</style>");
  if ($.browser.safari){ $("head").find("style:last").append(" ") }</script>

into the html-header. Please have a look at the validation output in the attachment.

hickory’s picture

You can ignore that, it's a bug in the validator.

smitty’s picture

Thanks’ for this information. Is this bug documented anywhere? Will this be fixed in the validator?

I tried some other validators. But every validator I found via Google showed the same validation message.

Do you know a validator which works properly?

hickory’s picture

Status: Active » Closed (fixed)

Just ignore it, it really doesn't matter.

smitty’s picture

Sorry, I really don't want to bother you. I'm only looking for an explanation for my customers, who expect a 100% error-free site.

hickory’s picture

You should file a bug report with the validator, in that case.

smitty’s picture

Status: Closed (fixed) » Active

I posted this problem on the w3-validator-mailing-list: http://lists.w3.org/Archives/Public/www-validator/2008Feb/0036.html

Here is a summary what I got back:

- The sript is ok.
- The validator is ok.
- The problem is the validation of the script inside an HTML file.

E.g. Rui del-Negro wrote:

If you want the HTML file to be valid, then _everything_ inside it (including scripts) must follow HTML rules. That means, for example, that all "<" signs inside the scripts must be replaced with "<". And all "&" signs must be replaced with "&", and so on (otherwise they are treated as normal tags, not as code that will _generate_ tags).

If you don't want to replace all those characters, there is a simpler solution: put the javascript in a separate file (ex., "myscripts.js") and load / execute that file like this:

<script type="text/javascript" src="myscripts.js" ></script>

That way it doesn't have to comply with HTML rules, because it's not inside an HTML file.

So, why don't you create a function (e.g. in the "jrating.js") and execute that function to get the work done?

hickory’s picture

Assigned: Unassigned » hickory

I'm sure there was a reason why it was set up this way, but can't remember what it was any more, so maybe it should move into jrating.js.

smitty’s picture

Status: Active » Needs review
StatusFileSize
new670 bytes

According to the hints in http://javascript.about.com/library/blxhtml.htm I inserted some comment-syntax and now the parser errors are gone.

Please have a look at the attached patch.