Search code examples
asp.nethtmlframesonmouseup

How do I save a frame splitter position and restore it later?


I have a web application where the window contains a frameset with two frames split vertically. I want the web application to remember where the frame splitter line was moved to, so that the next time the page is loaded, the frame splitter is drawn at the position where it was left.

How do people normally do this?

Currently, after a user has dragged the splitter to the new position, I am trying to use the onmouseup event to obtain the clientWidth of the left frame and store the clientWidth in a database for later retrieval. The problem is getting the clientWidth of the frame during the onmouseup event is not returning the width of the frame at the new splitter position, rather, it is returning the width of the frame at the old position. It seems that at the onmouseup event, the splitter has not rendered at the new position yet, as a result, my application is not loading the page with the splitter at the last saved position.


Solution

  • Instead of using the onmouseup event, I used the onresize event of the frame, which gives me the position of the splitter at the new position.