admin管理员组文章数量:1026298
I'm trying to resize a browser (I know... I know...) by the width only, and would like to maintain the users current height of the browser and I'm struggling to get it working correctly under IE8.
if I do:
window.resizeTo(document.documentElement.clientWidth, document.documentElement.clientHeight);
Which should in theory, maintain the exact same size, I'm losing roughly 176 pixels from the height... and roughly about the width of the scrollbar.
I can't find any properties which would give me the correct size of the entire browser window.
I'm trying to resize a browser (I know... I know...) by the width only, and would like to maintain the users current height of the browser and I'm struggling to get it working correctly under IE8.
if I do:
window.resizeTo(document.documentElement.clientWidth, document.documentElement.clientHeight);
Which should in theory, maintain the exact same size, I'm losing roughly 176 pixels from the height... and roughly about the width of the scrollbar.
I can't find any properties which would give me the correct size of the entire browser window.
Share Improve this question asked Aug 14, 2009 at 3:02 ChadTChadT 7,7232 gold badges43 silver badges59 bronze badges1 Answer
Reset to default 3This isn't the best solution, but it works.
First, save the current reported height:
var oldY = document.documentElement.clientHeight;
Second, set the window size to an a known size:
window.resizeTo(800, 600);
Next determine the amount of padding by subtracting the reported size from the known size:
var padX = 800 - document.documentElement.clientWidth;
var padY = 600 - document.documentElement.clientHeight;
Finally, set the width to the desired value plus padX
, and the height to the oldY
plus padY
.
window.resizeTo(desiredWidth + padX, oldY + padY);
The downside to this method is that the user may notice the window changing size at the second step of the process.
I'm trying to resize a browser (I know... I know...) by the width only, and would like to maintain the users current height of the browser and I'm struggling to get it working correctly under IE8.
if I do:
window.resizeTo(document.documentElement.clientWidth, document.documentElement.clientHeight);
Which should in theory, maintain the exact same size, I'm losing roughly 176 pixels from the height... and roughly about the width of the scrollbar.
I can't find any properties which would give me the correct size of the entire browser window.
I'm trying to resize a browser (I know... I know...) by the width only, and would like to maintain the users current height of the browser and I'm struggling to get it working correctly under IE8.
if I do:
window.resizeTo(document.documentElement.clientWidth, document.documentElement.clientHeight);
Which should in theory, maintain the exact same size, I'm losing roughly 176 pixels from the height... and roughly about the width of the scrollbar.
I can't find any properties which would give me the correct size of the entire browser window.
Share Improve this question asked Aug 14, 2009 at 3:02 ChadTChadT 7,7232 gold badges43 silver badges59 bronze badges1 Answer
Reset to default 3This isn't the best solution, but it works.
First, save the current reported height:
var oldY = document.documentElement.clientHeight;
Second, set the window size to an a known size:
window.resizeTo(800, 600);
Next determine the amount of padding by subtracting the reported size from the known size:
var padX = 800 - document.documentElement.clientWidth;
var padY = 600 - document.documentElement.clientHeight;
Finally, set the width to the desired value plus padX
, and the height to the oldY
plus padY
.
window.resizeTo(desiredWidth + padX, oldY + padY);
The downside to this method is that the user may notice the window changing size at the second step of the process.
本文标签: javascriptGet height of enter browser window in ie8Stack Overflow
版权声明:本文标题:javascript - Get height of enter browser window in ie8 - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745623260a2159706.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论