Solved

Cross browser scroll width when zoomed.

Posted on 2014-11-27
1
156 Views
Last Modified: 2014-12-03
At this (http://htmldoodads.appspot.com/dimensions.html) link the the scrollbar width is calculated when you zoom it in or out.
But it is working only for chrome not  working for IE 9
I did not check the other browsers. Can anybody make this functions cross browser using pure JS?
Thank you..

The function is:


var outerDiv = document.createElement('div');
outerDiv.style.width = outerDiv.style.height = '500px';  // enough for all the scrollbars
var div = outerDiv;
for (var i = 0; i < 10; ++i) {
  var child = document.createElement('div');
  child.style.overflowY = 'scroll';
  div.appendChild(child);
  div = child;
}
document.body.appendChild(outerDiv);
var outerDivWidth = outerDiv.clientWidth;
var innerDivWidth = div.clientWidth;
var scrollbarWidthCss = (outerDivWidth - innerDivWidth)/10;
document.body.removeChild(outerDiv);
return scrollbarWidthCss;
0
Comment
Question by:myyis
1 Comment
 
LVL 78

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
ID: 40469850
works with ie 9,10,11.. script error ie 8
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now