Home > Article > JQuery get size of iframe content

JQuery get size of iframe content

It does not works for the cross-domain, but works fine in same domain .


$('iframe').load(function () {
var doc = this.contentWindow.document;
var height = Math.max(
doc.body.scrollHeight || 0,
        doc.documentElement.scrollHeight || 0,
        doc.body.offsetHeight || 0,
        doc.documentElement.offsetHeight || 0,
        doc.body.clientHeight || 0,
        doc.documentElement.clientHeight || 0
    );
    var width = Math.max(
        doc.body.scrollWidth || 0,
        doc.documentElement.scrollWidth || 0,
        doc.body.offsetWidth || 0,
        doc.documentElement.offsetWidth || 0,
        doc.body.clientWidth || 0,
        doc.documentElement.clientWidth || 0
    );
};
Advertisements
Categories: Article
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: