views:

59

answers:

1

Hi, i have an ebook(relatively large size say 800 pages),in HTML format. I am opening that book as webpage using webkit-gtk+. If i load the whole book at a time,it takes too much memory(RAM ).So i dont want to load the whole book at a time, but load the part of the book which is currently on display. and when the user scrolls down, next part should be displayed.How can i implement that ?

+1  A: 

The most simple solution is to cut the book into pages and then use links at the top and bottom to move between them.

If you really want to try the "endless scrolling book" metaphor, then you must also split the book into pages on the server. Now, you can use JavaScript to watch for the scrolling events and load the next page with AJAX as soon as the visitor comes close to the edge.

The problem here is when to get rid of the parts the visitor has read. Also, the scroll bar will jump around a lot. So the experience for the user won't be that great either way. To get an idea how it feels, load a huge RSS feed into Google Reader. It won't drop articles that you've seen, so the browser slowly eats more and more memory. On the positive side, the scroll bar doesn't jump that madly.

Aaron Digulla
well, thanks, one thing i might not be very clear while mentioning,the HTML page i refered will be on my harddisk only, not in some other system/server. i will just be opening the page present in my computer system...
ganapati
That doesn't change my answer. You can't chop a huge single-file HTML book into smaller pages without loading the whole book into RAM.
Aaron Digulla
Or maybe you were confused by "on the server": Your own computer is the server in this case.
Aaron Digulla