Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Cross browser scroll width when zoomed.

Posted on 2014-11-27
1
162 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 80

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
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)
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.

808 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