JS dynamic access to scroll bar width javascript,js

Source: Internet
Author: User
javascript|js| Dynamic I now have a layer, there is a div in the layer, when the content is more often appear in the scroll bar, I now think, when the scroll bar appears, the width of the table div is equal to the width of the div minus the width of the scroll bar, how to dynamically get the width of the scroll bar, Or to determine whether the state of the scroll bar appears.
------------------------------------------------------------------------------------
Is that what you want?
<div id= "Demo" style= "Width:200px;height:100px;background-color:buttonface;overflow:auto;" >
Never-online<br/>never-online<br/>never-online<br/>never-online<br/>never-online<br />never-online<br/>never-online<br/>never-online<br/>
</div>
<div id= "D2" style= "Position:absolute;background-color: #eee;" ></div>
<script>
alert (demo.offsetwidth);
alert (demo.scrollwidth);
With (D2.style) {
Top=demo.offsettop;
Left=demo.offsetleft;
Width=demo.scrollwidth;
Height=demo.offsetheight;
}
</script>
--------------------------------------------------------------------------------------If I don't get it right, can I just cut it?

<div id= "Demo" style= "Width:200px;height:100px;background-color:buttonface;overflow:auto;" >
Never-online
</div>
<div id= "D2" style= "Position:absolute;background-color: #eee;" ></div>
<script>
Alert ("div width:" +demo.offsetwidth);
Alert ("div scrolling width:" +demo.scrollwidth);
Alert ("ScrollBar width:" + (parseint (demo.offsetwidth)-parseint (demo.scrollwidth));
demo.innerhtml = "never-online<br/>never-online<br/>never-online<br/>never-online<br/> Never-online<br/>never-online<br/>never-online<br/>never-online<br/> "
Alert ("div width:" +demo.offsetwidth);
Alert ("div scrolling width:" +demo.scrollwidth);
Alert ("ScrollBar width:" + (parseint (demo.offsetwidth)-parseint (demo.scrollwidth));
With (D2.style) {
Top=demo.offsettop;
Left=demo.offsetleft;
Width=demo.scrollwidth;
Height=demo.offsetheight;
}
</script>

--------------------------------------------------------------------------------------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.