Web 2.0 Equivalent to Web 1.0 TextArea.ScrollPosition?

I’m in the process of converting a Web 1.0 project to Web 2.0 and I need to make a WebTextArea scroll to the End of the text that I could use Scroll Position for in a Web 1.0. I’ve done some searching and I found that I can put the cursor at the end of the text using the following code, but the WebTextArea does not scroll to the cursor position as I had hoped.

Var pos as string = ProcessingLogsCC1.TextArea_Transaction.Text.Length.ToString
ProcessingLogsCC1.TextArea_Transaction.ExecuteJavascript “document.getElementById(’”+ProcessingLogsCC1.TextArea_Transaction.ControlID+"_inner’).setSelectionRange("+pos+", “+pos+”);"

Does anyone know of a way to use javascript in a similar fashion to actually scroll to the end of the text in a Text Area?


It is extremely frustrating that Xojo eliminated ScrollPosition. I’ve tried several things by searching Javascipt for scroll to bottom which essentially set ScrollTop = ScrollHeight but I can’t seem to get it to work.

ProcessingLogsCC1.TextArea_Transactions.ExecuteJavascript “document.getElementById(’”+ProcessingLogsCC1.TextArea_Transactions.ControlID+"_inner’).scrollTop = document.getElementById(’"+ProcessingLogsCC1.TextArea_Transactions.ControlID+"_inner’).scrollHeight;"

This code fails silently and does nothing. I’m probably doing something wrong, but I never used Javascript prior to web 2.0 other than a snippet here or there I’ve discovered in this forum. Having to learn another language because the one I’ve been using has eliminated functionality is not what I expected from a rapid development environment I’ve been using for 20 years. It irks me that little stupid things like missing scroll position switching from Web 1 to web 2 is a complete showstopper for me. Xojo becomes much harder to use and migrating code takes 3 times as long as it should and some things seemingly cannot be accomplished in the new web 2.0 framework. I really want to move on and switch to Web 2, but the process is maddening. Arrrrggghhhh!!!

Maybe one day Web 2 will be feature complete and with less bugs. For now, I dont really see any thing that make moving to it worth the long list of problems, lost of functionality, hacks and workarounds that moving would requiere.

1 Like

And yet it doesn’t make much sense to me to create new web applications using the Web 1.0 framework which will eventually have to also be converted to Web 2.0 sometime in the future when Web 2.0 is at least comparably feature complete to Web 1.0. I’ve mostly figured out how to stylistically work around the Bootstrap style limitations and utilize some of the bootstrap style advantages, but things like leaving out the WebTextArea ScrollPosition is just a mind boggling omission that shouldn’t have happened. I’m sure @Greg_O_Lone is tired of hearing complaints about these things, but I’m really trying to make Web 2.0 work for me and when I try to duplicate some functionality I could easily create with 1.0 I constantly run into roadblocks. I’d love to hear why ScrollPosition was left out of WebTextArea and when we can expect some level of scroll control in Web 2.0 or at a minimum how to work around the missing feature. I’m at an impasse with my current project and in the worst kind of mood as result. I’m not going to go backwards to Web 1.0 on this one, but I also have no idea how I’m going to move forward if I can’t get a WebTextArea to scroll to the end of the text.

Place in a module.

Public Sub scrollToBottom(extends t as WebTextArea)
  '// TextArea1.scrollToBottom
  if Session <> Nil then
    session.ExecuteJavaScript( "var container = document.getElementById('" + t.ControlID + "_field');container.scrollTop = container.scrollHeight - container.clientHeight;" )
  end if
End Sub

Call as


Thank you so very much Anthony. This is brilliant and EXACTLY what I was looking for as a solution.


Happy to help! Don’t forget to mark a solution so others can easily find it in the future if they need it.