How can I determine if my web page has scrollbars or not?

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

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: 339, Answers: 20)
Asked on April 29, 2015 10:54 pm
8 views
Answers (1)
1
Private answer

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

' used http://www.archives.gov/exhibits/charters/constitution_transcript.html
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''

Err.Clear

End If
msgbox result

GetScrollBarState = result

End Function

Code source (with modifications): http://www.advancedqtp.com/check-if-page-has-scrollbars/

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