How can I determine if my web page has scrollbars or not?
Question ID: 106077

I need to determine if my web page has scrollbars or not. Is there any way to do this?

Marked as spam
Posted by (Questions: 386, Answers: 64)
Asked on April 29, 2015 10:54 pm
Answers (1)
Private answer

I found the following code which will let you know if you have scrollbars or not.

' used
Set documentObject = Browser(''Transcript of the Constitution'').Page(''Transcript of the Constitution'').Object

blScrollbarv = (GetScrollBarState(documentObject, ''v''))
blScrollbarh = (GetScrollBarState(documentObject, ''h''))

msgbox ''Vertical Scrollbar?'' & blScrollbarv
msgbox ''Horizontal Scrollbar?'' & blScrollbarh

Function GetScrollBarState(ByVal document, ByRef scrollbarDir)
Dim result

Dim root

On Error Resume Next

Select Case LCase(document.compatMode)

Case ''backcompat''

Set root = document.body

Case Else

Set root = document.documentElement

End Select

Select Case LCase(scrollbarDir)

Case ''h''

scrollbarDir = ''horizontal''

result = (root.scrollWidth > root.clientWidth)

Case ''v''

scrollbarDir = ''vertical''

result = (root.scrollHeight > root.clientHeight)

End Select

If Err.Number <> 0 Then

Reporter.ReportEvent micWarning, ''GetScrollBarState'', ''Could not get state for '' & scrollbarDir & '' scrollbar''

result = ''Undefined''


End If
msgbox result

GetScrollBarState = result

End Function

Code source (with modifications):

Marked as spam
Posted by (Questions: 16, Answers: 807)
Answered on April 29, 2015 10:55 pm
That's great, thanks!
( at April 29, 2015 10:55 pm)

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

Scroll to Top