In a cross domain scenario I need to know what's in the iframe size (width and height) when the javascript code running inside the iframe. (I can't climb to the parent because I'm in a cross domain iframe) Note: I don't want to use jquery. I tried several ways to get that info:
var w = window.innerWidth || window.document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth || document.body.offsetWidth
var h = window.innerHeight || window.document.documentElement.clientHeight || document.getElementsByTagName('body')[0].clientHeight || document.body.offsetHeight
So, are you trying to access an iframe on another domain? You can't, because of XSS protection.
Here's a similar question: Get DOM content of cross-domain iframe
http://en.wikipedia.org/wiki/Cross-site_scripting
EDIT: Maybe this solution could give you an hint on what to do http://paulasmuth.com/blog/dynamic_height_crossdomain_iframe/ depending on the permissions you have on your pages.
If you want to get the window size, use this(excluding the scrollbar size if there is):
var w = document.documentElement.clientWidth;
var h = document.documentElement.clientHeight;
If you want to get the document size, use this(excluding the scrollbar size if there is):
var w = document.documentElement.scrollWidth;
var h = document.documentElement.scrollHeight;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.