clientWidth的问题《急》

wumeng53521 2009-07-22 03:34:29
有没有什么方法可以给document.body.clientWidth赋值啊?
...全文
93 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
wumeng53521 2009-07-22
  • 打赏
  • 举报
回复
我的想法是,用offsetWidth 减去clientWidth 得到的就是滚动条的宽度,然后用分辨率的宽度减去滚动条的宽度就间接的改变了clientWidth 的值,但是现在offsetWidth 和clientWidth 的值相同,何解?
virus7581 2009-07-22
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 toury 的回复:]
用resizeTo()
<script type="text/javascript">
  alert(screen.width+'/'+screen.height)
  resizeTo(screen.width/2,screen.height/2);
  alert(document.body.clientWidth)
</script>
[/Quote]
正解,想要改变位置的话可以用moveTo
toury 2009-07-22
  • 打赏
  • 举报
回复
用resizeTo()
<script type="text/javascript">
alert(screen.width+'/'+screen.height)
resizeTo(screen.width/2,screen.height/2);
alert(document.body.clientWidth)
</script>
wumeng53521 2009-07-22
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 virus7581 的回复:]
你想要做到什么样的功能啊?窗口打开时根据分辨率调整大小?
[/Quote]
virus7581 2009-07-22
  • 打赏
  • 举报
回复
你想要做到什么样的功能啊?窗口打开时根据分辨率调整大小?
wumeng53521 2009-07-22
  • 打赏
  • 举报
回复
没人知道么。。
wumeng53521 2009-07-22
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 cloudgamer 的回复:]
clientWidth是根据窗口大小定的
赋值要干嘛
[/Quote]

就是想根据分辨率自动给clientWidth赋值
cloudgamer 2009-07-22
  • 打赏
  • 举报
回复
clientWidth是根据窗口大小定的
赋值要干嘛
wumeng53521 2009-07-22
  • 打赏
  • 举报
回复
[Quote=引用楼主 wumeng53521 的回复:]
有没有什么方法可以给document.body.clientWidth赋值啊?
[/Quote]

不可以,他是只读属性
FangYANYI 2009-07-22
  • 打赏
  • 举报
回复
直接赋值就可以了?

87,915

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧