<?xml version="1.0" encoding="utf-8"?>

<feed xmlns="http://www.w3.org/2005/Atom">
<title>Tyler Cipriani: Cross-Browser JavaScript Scrollbar Detection</title>
<link href="https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/"/>
<link href="https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/comments.atom" rel="self" type="application/atom+xml"/>
<author>

<name>Tyler Cipriani</name>

</author>

<rights type="html" xml:lang="en">

	<a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike License</a>
	Copyright © 2017 Tyler Cipriani

</rights>


<id>https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/</id>

<subtitle type="html">Tyler Cipriani</subtitle>
<generator uri="http://ikiwiki.info/">ikiwiki</generator>
<updated>2018-06-13T19:34:11Z</updated>
<entry>
	<title>comment 1</title>

	<id>https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/comment_1_d692aec480382f1feb603775b1eb3b43/</id>

	<link href="https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/#comment-92ec281ac89e347be9720b0882730ce0"/>

	<author><name>ilycite</name></author>





	<updated>2018-06-13T19:34:11Z</updated>
	<published>2015-01-25T02:53:12Z</published>


	<content type="html" xml:lang="en">
	&lt;p&gt;Hello, great work. I adapted your code to let the possibility to chose on which axe the check is made. Here the code : &lt;a href=&quot;https://gist.github.com/numee/1e7a19cd26113323f1ae#file-hasscrollbar&quot;&gt;https://gist.github.com/numee/.. .&lt;/a&gt;.&lt;/p&gt;


	</content>



</entry>
<entry>
	<title>comment 2</title>

	<id>https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/comment_2_87255105c68d92f7653d4f5ef7a807fb/</id>

	<link href="https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/#comment-5f410750fdb1ccaf331d1764d01bbc14"/>

	<author><name>clottes.code</name></author>





	<updated>2018-06-13T19:34:11Z</updated>
	<published>2015-07-17T13:35:13Z</published>


	<content type="html" xml:lang="en">
	&lt;p&gt;// rootElem for quirksmode&lt;/p&gt;
&lt;p&gt;var rootElem = document.documentElement || document.body&lt;/p&gt;
&lt;p&gt;shouldn’t you be checking if the clientHeight of document is 0 (not that documentElement exists) when assigning rootElem… (if I’m following your resoning above)&lt;/p&gt;
&lt;p&gt;isn’t this what you mean:?&lt;/p&gt;
&lt;p&gt;var rootElem = document.documentElement&lt;/p&gt;
&lt;p&gt;if(!rootElem.clientHeight) rootElem = document.body&lt;/p&gt;


	</content>



</entry>
<entry>
	<title>comment 3</title>

	<id>https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/comment_3_6c38fd1605b818f290322b062c4d6cce/</id>

	<link href="https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/#comment-71462ced4f857a1102514a2a4f1a6ac8"/>

	<author><name>clottes.code</name></author>





	<updated>2018-06-13T19:34:11Z</updated>
	<published>2015-07-17T13:39:47Z</published>


	<content type="html" xml:lang="en">
	&lt;p&gt;Note: that rootElem in my previous comment would only be viable then in the rest of the code for calculating things available on that element and would require changing, my point is rootElem will always be document.documentElement (because it exists in IE8 if I’m not mistaken)&lt;/p&gt;


	</content>



</entry>
<entry>
	<title>comment 4</title>

	<id>https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/comment_4_d29a0942039bd4e76d848767ea0c7e7f/</id>

	<link href="https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/#comment-014aebc25f7b33d87fb74d38604f0f84"/>

	<author><name>ashraf.reda.m</name></author>





	<updated>2018-06-13T19:34:11Z</updated>
	<published>2016-07-17T02:49:20Z</published>


	<content type="html" xml:lang="en">
	Works Great, Thanks..

	</content>



</entry>
<entry>
	<title>Great stuff</title>

	<id>https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/comment_5_6b75facb84407c1d7f52bf93f411db56/</id>

	<link href="https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/#comment-5cb2d9a051e4aa616cd9a09026841890"/>

	<author><name>franciskim</name></author>





	<updated>2016-12-01T04:42:56Z</updated>
	<published>2016-12-01T04:42:55Z</published>


	<content type="html" xml:lang="en">
	Seems like the best answer I’ve found to this problem, thank you.

	</content>



</entry>
<entry>
	<title>Using the code</title>

	<id>https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/comment_6_0d1a9d858600fd24c7e8cfede74fcf60/</id>

	<link href="https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/#comment-75dba0279c2b2934bad6cdd94bf6eb43"/>

	<author><name>glinnewe</name></author>





	<updated>2017-05-05T18:36:13Z</updated>
	<published>2017-03-29T14:44:06Z</published>


	<content type="html" xml:lang="en">
	&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for the great write up!&lt;/p&gt;
&lt;p&gt;Could you please go until a bit more detail regarding how we would apply the code?&lt;/p&gt;
&lt;p&gt;For example, I’d like to do a check to see if the scrollbar exists and is pushing the content over and, if so, then add a class to the body. How would this be done?&lt;/p&gt;
&lt;p&gt;I basically want to be able to do the following:&lt;/p&gt;
&lt;p&gt;if ( hasScrollBar ) { $(‘body’).addClass(‘window_has_scrollbar’); }&lt;/p&gt;


	</content>



</entry>
<entry>
	<title>Works very well</title>

	<id>https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/comment_7_c18ca1a381df8789006adac9f8e92777/</id>

	<link href="https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/#comment-9f6a47b0ca37271ae708d7b0eba1164c"/>

	<author><name>riophaelee</name></author>





	<updated>2017-05-13T18:17:06Z</updated>
	<published>2017-05-13T18:17:05Z</published>


	<content type="html" xml:lang="en">
	Thank you!

	</content>



</entry>

</feed>
