error reported parsing style properties 'left' & 'top'




11 years ago
11 years ago


(Reporter: Tom Nielsen, Unassigned)


Firefox Tracking Flags

(Not tracked)





11 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20070914 Firefox/
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20070914 Firefox/

When a DTD is present (HTML 4.01 Transitional or XHTML 1.0) Firefox reports:
  Error in parsing value for property 'left'. Declaration dropped.
  Error in parsing value for property 'top'. Declaration dropped.
If DTD omitted, no error.

Reproducible: Always

Steps to Reproduce:
1. load page
2. click small icon at bottom of a concept symbol
Actual Results:  
popup always appears in upper left corner of window

Expected Results:  
popup appears at cursor location where icon was clicked

1. Works as expected if DTD is removed from the page.
   See: <URL: >.
2. Works with DTD correctly in Opera 9.23
3. FWIW, in IE7 popup appears offset from expected location by amount of scroll

Comment 1

11 years ago
Are you providing units when you set those styles?  Units are required.  

Comment 2

11 years ago

Brian is right. This code:

    if (document.all) {                 // Internet Explorer Detected
	   IE = true;	
    else if (document.layers) {         // Netscape Navigator Detected
	   NS = true;	
    else if (document.getElementById) { // Netscape 6 Detected
       GECKO = true;

Netscape 6, NS 7, NS 8, NS 9 do not support layers collection;
Opera 6+ supports document.all. All the above code is not the proper way and recommended way to do browser detect.

	if (GECKO)
	    document.getElementById(popupName).style.left = event.layerX;
	    document.getElementById(popupName) = event.layerY;

is very wrong as layerX/layerY are integer values, not parsable length units.
The Error console in Firefox was already indicating the source of the problem.

Please visit
Using Web Standards in your Web Pages
Section W3C DOM2 Reflection of an Element's CSS Positioning Properties

CSS 1 Forward-compatible parsing


CSS 2.1 Rules for handling parsing errors

clearly states that length values must have units.

You mentioned Opera 9.23 but
"CSS size and position properties specified without a unit
Unit-less numbers in CSS (e.g. 'width: 300') are interpreted as pixels in Quirks Mode and ignored in Standards Mode."

Implement the W3-dev toolbar in Opera 9 and then verify that the webpage triggers standards compliant rendering mode.

Also, your browser sniffing code will absolutely create problems in short and long term.
Please consult

Using Web Standards in your Web Pages
 4 Developing Cross Browser/Cross Platform Pages

  4.1 Browser identification approach (aka "browser sniffing"): not best, not reliable approach
  4.2 Using Object/Feature support detection approach: best and overall most reliable

A Strategy That Works: Object/Feature Detecting by comp.lang.javascript newsgroup FAQ notes

Browser detection - No; Object detection - Yes by Peter-Paul Koch

Resolving as INVALID
Last Resolved: 11 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.