How to get initial and on resize sizes of elements and window?

I need to bind the window and/or a element width and height to variables. How could I do this?

i think this stackoverflow post should get you heading in the right direction -