By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,520 Members | 1,251 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,520 IT Pros & Developers. It's quick & easy.

Error parsing value for property 'top'

P: n/a
Tom
I have a function which finds the x and y coordinate of any object in
the document by referring to offsetLeft or offsetTop value of the
object's offsetParent, all the way to the top of the DOM, i.e.:

function get_y(obj) {
var coord = 0;
while (obj.offsetParent) {
coord += obj.offsetTop;
obj = obj.offsetParent;
}
return coord;
}

function get_x(obj) {
/* same as above function, but with offsetLeft in place of offsetTop
*/
}

Now, I've tested this function out many, many times on documents built
using table models, and it works perfectly. However, I tried to import
the same function to a document using a CSS model without any tables
and it fails on the y-coord function ONLY -- the x-coord function
(offsetLeft) works just as it would on a document using the table
model, but the y-coord function produces the following error in a CSS
model:

"Line 0: Error parsing value for property 'top'; Declaration dropped"
(moz error -- IE returns "Invalid argument Line 0")

I'm unable to figure out what the problem is. I'm assuming I've left
out a certain required parameter in my stylesheet, but I don't know
what it could be!

Any insight would be appreciated!

Oct 10 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a


Tom wrote:

"Line 0: Error parsing value for property 'top'; Declaration dropped"
(moz error
That error message is given by Mozilla's CSS parser and essentially
means that you/your stylesheet(s) give an incorrect value for the CSS
top property e.g. instead of having
top: 20px;
you might have only
top: 20;
which is not correct CSS. So check your stylesheet or your script
setting the CSS top property to supply a proper CSS value (i.e. number
plus unit).

--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 10 '06 #2

P: n/a
Tom
That error message is given by Mozilla's CSS parser and essentially
means that you/your stylesheet(s) give an incorrect value for the CSS
top property e.g. instead of having
top: 20px;
you might have only
top: 20;
which is not correct CSS. So check your stylesheet or your script
setting the CSS top property to supply a proper CSS value (i.e. number
plus unit).
Which object though? I don't have the top property defined anywhere in
my stylesheet (all the elements are floating).

The function successfully finds the offsetTop for all div elements, but
somewhere near the top of the DOM this error pops up. The fact that
position is not defined anywhere doesn't seem to affect the function's
ability to get the offsetLeft value, but it does for offsetTop. Any
thoughts?

Oct 10 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.