I have an iframe on a page on the same domain. I need to get the scrollheight of the page which is displayed in the iframe to determine whether the vertical scrollbar is displayed or not. For example, if (iframe document height > iframe window height) it means that scrollbar is displayed. Iframe window height is a constant value defined by CSS (320px) but how can I get the document height of the page displayed in the iframe?

I tried the following:

but it gives the height of the iframe. I also tried some jQuery without any success.

The reason why I need to figure out whether the scrollbar is displayed or not is because I am controlling the width of the iframe based on that.