admin管理员组文章数量:1333404
how can you set the body width in px in javascript?
has to work in chrome, ff and our beloved ie
edit:
it has to be used when a dialog box pops up and the horisontal scrollbar is hidden.. then I have to pensate for the missing 16px.. else the whole site is moving slightly to the right
maybe you have better solution to the problem? I don't know :)
how can you set the body width in px in javascript?
has to work in chrome, ff and our beloved ie
edit:
it has to be used when a dialog box pops up and the horisontal scrollbar is hidden.. then I have to pensate for the missing 16px.. else the whole site is moving slightly to the right
maybe you have better solution to the problem? I don't know :)
Share Improve this question asked Apr 24, 2011 at 7:56 clarkkclarkk 1 3- What do you mean by "body width"? Please add more detail – Pekka Commented Apr 24, 2011 at 7:58
- Re your edit: I don't think changing the body's width will help you in that case. Is the dialog box an iframe? – Pekka Commented Apr 24, 2011 at 8:00
- no.. its a div box placed in the center and middle – clarkk Commented Apr 24, 2011 at 8:01
2 Answers
Reset to default 4document.body.style.width = '800px';
[Edit]
If you need to adjust from the existing width, per your edit, you could do something like this:
var adjustBodyWidth = function(nPixels) {
var m, w = document.body.style.width || document.body.clientWidth;
if (m=w.match(/^(\d+)px$/)) {
document.body.style.width = (Number(m[1]) + nPixels) + 'px';
}
};
If the problem is the scroll bar ing up and disappearing depending on the page's contents, I would consider forcing the page to display a (disabled) scroll bar even when there's nothing to scroll. This can be done through CSS:
body { overflow-y: scroll }
it works in all major browsers. It doesn't in IE, but that doesn't matter because IE shows the desired behaviour automatically.
本文标签: javascriptset body width in pxStack Overflow
版权声明:本文标题:javascript - set body width in px? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742335330a2455509.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论