I want to set the width of an <iframe>
based on the browser's width and height.
Is it possible to get the browser's width in pixels using JavaScript?
If you don't want to use jQuery, to determine the actual size of the browser window, use the following properties:
in Internet Explorer (quirks mode):
document.body.offsetWidth
in Internet Explorer < 9 (standards mode):
document.documentElement.offsetWidth
in most other browsers:
window.innerWidth
you can try this.
var objlast = document.getElementById('lastdiv');
if (objlast.offsetParent) {
do {
curleftLast += objlast.offsetLeft;
curtopLast += objlast.offsetTop;
} while (objlast = objlast.offsetParent);
}
document.getElementById('iframe').style.height = curtopLast+"px";
this will also work, and lastdiv would be the endpoint of your window from where you want to fetch window height.
Thanks.