views:

1806

answers:

4

before posting the whole code, i wanted to make sure I am not missing a simple issue here.

var dv = $(myElement);

var pos = dv.offset();
var width = dv.width();
var height = dv.height();

alert(pos);
alert(width);
alert(height);

here, width alerts fine, height alerts fine but offset alerts [object Object] (in firefox)

am I missing something here?

+3  A: 

that's correct: the offset() function returns an object containing two properties, left and top. (See the docs). "[object Object]" is how most objects are converted to strings.

I'd suggest you install Firebug to help you with debugging Javascript like this as it would give you much better information about the variables.

nickf
A: 

:S I do apologise for consuming the valuable resources of this website by asking such a question which required client and server side validation, had to access a database and consumed internet bandwidth!!!! thats my anger to self! Think I should get some sleep now.. thanks guys...

Emin
haha don't sweat it - this page will be a saviour to a fellow sleep-deprived programmer one day...
nickf
+1  A: 

and also test with console.log() rather then alert()

adardesign
using console.log() can break IE if forgotten
vsync
A: 

Related Issue:

in Firefox 3.0.x and earlier Safari windows versions, I am getting offset return nil or 0 when all other browsers are fine.

Is this a known issue with a known work-around?

Roger
Better post this as a new question--it's not an answer to this question and more people will see it and not many people will look at it here. The "Ask Question" button is in the top right of the page.
sth