How to find the width of the div or check wheather horizontal scroll apeear or not?

I want to print the page (div) if there is no horizontal scroll appear for that div. I have a div (1000px) with dynamic data which having property overflow:auto;. So, i want to print the div only if div's width is not getting crossed. to achieve this i used following method of a javascript

var curr_width = parseInt(mydiv.style.width);

But it gives 1000px; only althogh i can see horizontal scrollbar for the div.

What should i do to achive this.

Can i check wheather horizontal scrollbar is appear for the div or not.

Any help is appreciated.

NOTE:- i don't want to use any javascript library.

-------------Problems Reply------------

scrollWidth, clientWidth did the trick

var mydiv = document.getElementById("grid_print");
if (mydiv.scrollWidth > mydiv.clientWidth){
alert("limit exceeds")
}

Category:javascript Views:0 Time:2010-06-17

Related post

  • Should I Have a div with the Width of 100% When the Content Forces Horizontal Scrolling? 2012-02-20

    I have a webpage where I have a header section and then some content. In the content, I have a grid and some of the views show many columns which (depending on the screen size) will create a horizontal scroll bar on the browser) my html looks like so

  • Attach a div to Dojo DataGrid horizontal scroll 2009-07-29

    I have a fixed width datagrid being built programatically, and am trying to put a header over top of it that will scroll with it. I can't do it as part of the grid as that destroys the fixed width of the cells. I would like to be able to scroll the t

  • Eliminate horizontal scrolling in div in favor of horizontal scrolling in browser window 2010-12-24

    I have a div, set to 800px wide, that will automatically scroll horizontally if the browser window is resized to < 800px. The behavior I would like, is to have the browser window scroll instead of the div. It would seem simple but for some reason

  • Jquery: Automatically сalculate div width to prevent horizontal scrolling 2010-07-24

    Have a "liquid" layout that has fixed width for left side and "elastic" right side. For some reasons can't change markup of the layout. The trouble is: Sometimes the right side becomes very wide (depending on the content inside) and horizontal scroll

  • HTML table - fixed width columns and horizontal scroll 2010-10-15

    I need to create an HTML table which has fixed column widths, say 200px for each column. If the table exceeds the horizontal width of the browser viewport then there should be horizontal scroll to view the columns which are off-screen. As the table i

  • How to measure the width of a div with overflow content 2009-05-28

    I have a div with a width of 200px. There is text inside that is set not to wrap. So there is overflow. I need to get the width of the content of the div including the overflow. I am using this for a YUI autocomplete dropdown menu. I want the dropdow

  • Set child element width to parent div 2009-09-15

    I'm having a parent div and inside that child element will be table. I'm hidding some columns in the table through CSS to avoid inline-style. So how can I reflect the width to parent div after hiding the column of table... --------------Solutions----

  • Chrome and fixed width on a div (or other tags) 2009-12-14

    I have some html which looks like this: <div style="{ display:inline; width: 80px}">fig</div>vitamin c<br> <div style="{ display:inline; width: 80px}">apple</div>vitamin a<br> <div style="{ display:inline; width

  • change width of a div dynamically 2010-01-31

    I am trying to change my "inner" div's width dynamically on the click that the images are changed (which works) with a similar script. I cannot get the script to work, any help fixing it, or changing it would be appreciated. I am a noob in javascript

  • xHTML/CSS: How to make inner div get 100% width minus another div width 2010-02-04

    I have 2 nested divs inside outer one, which has width:100%. Both nested divs should be in one line and first should get it size from it's contents: <div id="#outer" style="width:100%; border:1px"> <div id="#inner1" style="border:1px; displa

  • How do I get a useful value for height and width of a div element using javascript? 2010-03-29

    I need to be able to store the current height and width of a div at any point in time. Currently I am using div.style.height/width which works fine when the styling is applied inline. The problem is that this returns for example 600px and not 600. Is

  • DIV is picking max-width value as width value for DIV 2010-06-08

    I am facing a problem after applying max-width hack for IE7. In mozilla, width of the div is flexible and adjustable as per the image width in the div. But in IE7 it is taking the max-width as width of DIV. Below is my HTML code: http://10.112.99.192

  • How to get the maximum possible width of a div? 2010-07-09

    I need to know how one can get the maximum possible width of a div. Generally, a <div>'s width is limited by it's parent, meaning that it can not be larger than a certain amount. How that certain amount can be calculated? I need this to calcula

  • Add width of a div element from code behind 2010-07-29

    In the aspx page I have div with id="progressBar" and runat="server".I need to add width of the div from code behind in C#. Can anyone help me how to do this? --------------Solutions------------- You can set it's Style property, like this: progressBa

  • How do I structure my HTML to give priority to a specific divs width over another div? 2010-08-23

    I need to create the following layout: +--------+----------------------------------+-----------+ | fixed | variable | variable | fixed | | width | width - p2 | width - p1 | width | +--------+-------------------+--------------+-----------+ Where the t

  • Why does the background for some elements extend across the width of the DIV and some don't? 2010-10-25

    I have a rather colorful background, and to make the text legible, it's set on a semi-transparent background. H1, P both show the background the full width of the divs. spans and as however only show the background for where they are. This latter beh

  • Margin of html element defaulting to fill width of containing div, cannot override 2010-12-23

    I'm a fairly novice web developer and I'm having a very fundamental problem that I would really appreciate some help with: No matter what width I set any elements within a certain containing div, safari and Chrome both add extra margins that fill the

  • How to find the width of a div 2011-01-24

    How do you find the current width of a div in a cross browser compatible way? EDIT: Without using a library like JQuery --------------Solutions------------- document.getElementById("mydiv").offsetWidth element.offsetWidth (MDC) You can use clientWidt

  • width of floated div pushed down 2011-02-18

    I have floated two divs left but the div on the right has a huge text(without br s) and it is pushed down what should i do in the css such that to make sure the right div does not push down I had tried giving it a width but width does not take the re

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.180 (s). 11 q(s)