tags:

views:

62

answers:

3

Hello.. I know that height() method of jquery returns a number unitless... How can i be sure that this number is in the unit i want?

I want to work with centimeter cm any ideas?

+3  A: 

the unit returned by height() is pixels.

converting that to cm might be difficult, as that depends on the user's monitor, size of pixels, etc.

question, why in gods name do you want cm?

mkoryak
A: 

height returns height in pixels. Unfortunately centimeters is going to be very difficult for you to work with. Monitors all have different pixel densities, and javascript does not have a way to know this pixel density. You'll have to estimate how many pixels average a centimeter and convert from there.

Average pixel density would have anywhere from 100-130px in a centimeter, as you can tell this is a pretty wide range.

Jeremy B.
A: 

I would like to do this only for a reports page in order to generate some pages A4... I would like to go to a new page (css page break) if it exceeds some cm...

Parhs
I would say the best way to do this (maybe the only way, not sure) would be to print out a page full of your reports on your printer, then count how many lines fit on one page, then enter a new heading (or whatever you want to do at a page break) after that number of lines. This can also happen server-side, and is assuming you don't have any fancy stuff on the page like graphs that may or may not be on a page. Just an idea.
bobsoap