我用来设置一个div作为整个页面的掩码。
$(document).width();但这在IE和Firefox之间表现不同。在IE中是796,而在firefox中是789。当我将蒙版的宽度应用为$(文档)时,.width();
在firefox中,口罩适合屏幕。但在IE中,下方会出现一个额外的滚动条。
我想让这个口罩适合屏幕。请帮我处理这件事。
当我调整窗口大小时,window.width()和100%不会有帮助。我不能在原地使用$('body'),因为我需要以同样的方式计算高度。
提前谢谢。
发布于 2011-07-07 21:10:28
从字面上看,这是一段试错和寻找全世界的日子。
使用pureJS是因为甚至jquery都没有正确地报告它!但是需要jquery来识别浏览器。我用它来测量iframe中的正文-以避免跨域通信中的滚动条。你可以稍微调整一下。但核心在那里
if ( $.browser.msie ) {
var thisH = thisFrame.scrollHeight;
var thisW = thisFrame.scrollWidth;
}
else if ( $.browser.opera )
{
var thisW = thisFrame.scrollWidth;
if (iframe.clientWidth > thisW ) {
thisW = 660; //These are custom- you can ignore it
}
var thisH = thisFrame.scrollHeight;
if (iframe.clientHeight > thisH ) {
thisH = 550; //These are custom- you can ignore it
}
}
//All other clients
else
{
var thisW = thisFrame.scrollWidth;
if (iframe.clientWidth > thisW ) {
thisW = 660; //These are custom- you can ignore it
}
var thisH = $(thisFrame).height();
if (iframe.clientHeight > thisH ) {
thisH = 550; //These are custom- you can ignore it
}
} 发布于 2011-09-09 22:55:17
http://www.javascripter.net/faq/browserw.htm
下面的代码将变量winW和winH设置为浏览器窗口的实际宽度和高度,并输出宽度和高度值。如果用户使用非常旧的浏览器,则将winW和winH分别设置为630和460。
var winW = 630, winH = 460;
if (document.body && document.body.offsetWidth) {
winW = document.body.offsetWidth;
winH = document.body.offsetHeight;
}
if (document.compatMode=='CSS1Compat' &&
document.documentElement &&
document.documentElement.offsetWidth ) {
winW = document.documentElement.offsetWidth;
winH = document.documentElement.offsetHeight;
}
if (window.innerWidth && window.innerHeight) {
winW = window.innerWidth;
winH = window.innerHeight;
}https://stackoverflow.com/questions/6611064
复制相似问题