开发者

Determine if ui layout pane has a scrollbar

开发者 https://www.devze.com 2023-04-04 14:59 出处:网络
Is it possible to determine if a UI.Layout pane has a scrollbar? My center pane has DIVs; one of the DIVs contains a jqGrid that I\'m trying to auto resize. Playing around with resize events, the grid

Is it possible to determine if a UI.Layout pane has a scrollbar? My center pane has DIVs; one of the DIVs contains a jqGrid that I'm trying to auto resize. Playing around with resize events, the grid resizes properly if there is no scrollbar. I believe if I could determine whether or not a scrollbar is there, I can better resize the g开发者_如何学Crid.

Thank You


Well you can create a new function like this to check for the existance of a scrollbar

$.fn.hasVerticalScrollBar = function () { 
  if (this[0].clientHeight < this[0].scrollHeight) { 
    return true 
  } else { 
    return false 
  } 
}  

$.fn.hasHorizontalScrollBar = function() { 
  if (this[0].clientWidth < this[0].scrollWidth) { 
    return true 
  } else { 
    return false 
  } 
}  

Usage:

alert($('#mydivid').hasHorizontalScrollBar()); 
alert($('#mydivid').hasVerticalScrollBar()); 
0

精彩评论

暂无评论...
验证码 换一张
取 消