poo
poo

Reputation: 1115

How to detect height of page inside iframe?

I have a iframe in a page

<iframe src="page.aspx" > 

I don't know how big the thing is going to be. How to get the height? May be jquery would be good here beacuse of browser indifferences.

// sth like this. 
currentfr.contentDocument.body.offsetHeight // NS 
currentfr.Document.body.scrollHeight // IE 

Upvotes: 0

Views: 301

Answers (1)

tabdulradi
tabdulradi

Reputation: 7596

like your code , but you enhance it a bit to avoid errors

if (window.innerWidth) { //if innerWidth is defined
      // the standard
      w = fr.width,
      h = fr.height
 }
else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0) {
       // IE6
       w = fr.document.documentElement.clientWidth,
       h = fr.document.documentElement.clientHeight
}

Upvotes: 2

Related Questions