如果您只是来告诉我为什么调整窗口大小是一个坏主意、令人讨厌,并且在网络上相当于粉笔板上的钉子,那么请走开。我正在寻找解决方案而不是讲座。这仅用于 Intranet 设置。具体来说,调试并演示响应式设计的网站(使用媒体查询进行扩展的网站),以供客户通过网络 session 进行审查。我想演示特定的断点。这不是向公众释放的。
我已经知道的事情:
可能的解决方案:
高度
我需要第 1 步的帮助。我能弄清楚的其他一切。如果有帮助的话,我也在使用 jQuery 和 Modernizer。
在此先感谢您的帮助!
最佳答案
这篇文章已经很老了,但这里有一个供 future 读者使用的具体实现:
var resizeViewPort = function(width, height) {
if (window.outerWidth) {
window.resizeTo(
width + (window.outerWidth - window.innerWidth),
height + (window.outerHeight - window.innerHeight)
);
} else {
window.resizeTo(500, 500);
window.resizeTo(
width + (500 - document.body.offsetWidth),
height + (500 - document.body.offsetHeight)
);
}
};
如果你想考虑滚动条:
var resizeViewPort = function(width, height) {
var tmp = document.documentElement.style.overflow;
document.documentElement.style.overflow = "scroll";
if (window.outerWidth) {
window.resizeTo(
width + (window.outerWidth - document.documentElement.clientWidth),
height + (window.outerHeight - document.documentElement.clientHeight)
);
} else {
window.resizeTo(500, 500);
window.resizeTo(
width + (500 - document.documentElement.clientWidth),
height + (500 - document.documentElement.clientHeight)
);
}
document.documentElement.style.overflow = tmp;
};
玩得开心...
关于javascript - 如何调整浏览器窗口的大小以使内部宽度为特定值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10385768/