javascript - Determine if an HTML element's content overflows -


can use javascript check (irrespective of scrollbars) if html element has overflowed content? example, long div small, fixed size, overflow property set visible, , no scrollbars on element.

normally, can compare client[height|width] scroll[height|width] in order detect this... values same when overflow visible. so, detection routine must account this:

// determines if passed element overflowing bounds, // either vertically or horizontally. // temporarily modify "overflow" style detect // if necessary. function checkoverflow(el) {    var curoverflow = el.style.overflow;     if ( !curoverflow || curoverflow === "visible" )       el.style.overflow = "hidden";     var isoverflowing = el.clientwidth < el.scrollwidth        || el.clientheight < el.scrollheight;     el.style.overflow = curoverflow;     return isoverflowing; } 

tested in ff3, ff40.0.2, ie6, chrome 0.2.149.30.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -