It's possible to check where the tags are positioned and get the lowest one and then calculate if the window needs a scrollbar or not. But you can't change a window's properties like scrollbars after you've opened it. Don't remember if it's the same thing with frames though..
You could try to set scrolling to auto, then it should autodetect it..