Error: document type does not allow element "style" here

hass - May 27, 2007 - 22:31
Project:jRating
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:hickory
Status:active
Description

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>

#1

hass - May 28, 2007 - 14:37

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.

#2

hickory - May 29, 2007 - 16:36
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.

#3

hass - May 30, 2007 - 22:15

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.

#4

hass - June 17, 2007 - 11:03

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.

#5

hickory - June 26, 2007 - 09:11

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...

#6

momper - October 29, 2007 - 16:51

hello

is there something new?

thanks and greetings
momper

#7

hickory - November 22, 2007 - 16:26
Version:5.x-1.0» 5.x-1.x-dev
Status:active» fixed

#8

Anonymous - December 6, 2007 - 16:31
Status:fixed» closed

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

#9

smitty - January 19, 2008 - 17:28
Status:closed» 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!

#10

hickory - January 21, 2008 - 15:34

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

#11

smitty - January 22, 2008 - 21:09

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

#12

smitty - February 4, 2008 - 14:25

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.

AttachmentSize
Validation-output.jpg 107.06 KB

#13

hickory - February 4, 2008 - 17:04

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

#14

smitty - February 13, 2008 - 15:42

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?

#15

hickory - February 13, 2008 - 15:48
Status:active» closed

Just ignore it, it really doesn't matter.

#16

smitty - February 14, 2008 - 10:06

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.

#17

hickory - February 14, 2008 - 10:07

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

#18

smitty - February 16, 2008 - 06:56
Status:closed» 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?

#19

hickory - October 16, 2008 - 11:54
Assigned to:Anonymous» 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.

 
 

Drupal is a registered trademark of Dries Buytaert.