ID:155904
 
I need a good way to have an HTML popup window that, when I output new text to it, will refresh to exactly where it was scrolled to instead of going to the top. I've tried a couple of things, but mostly just tricking it into thinking I didn't change the content at all, such as browse_rsc'ing the HTML over to the user in a file, and then outputting a frame containing the HTML file to the browser. There also doesn't appear to be a way to winset/winget the location of the scroll bars, or this would be easy. I'm pretty sure the solution has something to do with winset/winget or browse_rsc, but I'm not very familiar with either of them, so this is little more than a hunch.
mob/verb/Test() //Browser window opens; window is scrolled all of the way up usr << browse("LOTS OF TEXT! ENOUGH TO MAKE IT SCROLL!!",window="html_window") sleep(60) //Scroll down the page while this sleeps usr << browse("OH MAN! LOTS MORE TEXT! MAYBE EVEN MORE THAN BEFORE!",window="html_window") //Browser window refreshes and jumps all the way to the top. Ideally, it would still be wherever you scrolled to.
Maybe it can be done with a skin control I missed or something. Just hopefully it doesn't need a complicated workaround.</<></<>
Javascript is the solution for this. With it, you can change the content of the browser without redirecting and you can also control which part to view. There are many tutorials out there in the Internet. Good luck!
try the up_Form library, i think it can do refreshing of a page without scrolling to the top
What you can do is send (through a BYOND url) window.scrollTop when you want to save it (ie. on a window scroll event) via javascript (by setting window.location="byond://?...") and store it somewhere convenient (if you use a datum to represent a browser interface, there would be appropriate). Whenever you refresh the page through another browse call, set window.scrollTop to the stored value when you generate your HTML.

Be aware that attaching an event to window.scroll without programming any sort of timeout would send dozens of requests from the client browser to the server a second.
Thanks for the tips. Despite not knowing Javascript prior to this problem, I've got it working. It was pretty simple. I just made it save the form's scroll location whenever they scroll the page, and made it scroll to that location whenever the page was loaded.