views:

90

answers:

2

Hi, I am trying to display 10 html pages as a single document,with 10 chapters. I am using Webkitgtk+ engine to render the HTML pages. I am getting the content of each html files and concatenating all of them to create a
single 'char *content' and using webkit_web_view_load_html_string(WebKitWebView *web_view, const gchar *content, const gchar *base_uri); this function to load all the HTML files, as a document.

Now i am trying to build a 'table of contents(toc)' for this document, which displays all the chapter names in order. My requirement is, when i click on a particular chapter in toc, the document should scroll to that point. For that i need to know height of each chapter ( height of each html file content).

The point to be noted here is, the width of the document can changed and as HTML is reflowable, as width increases height decreases and vice-versa. So each time when height changes i need to find out the current height of each HTML page(or chapter) and hence calculate the distance to be scrolled.

How can i find out the height of content of HTML page dynamically ? Thank you for the answer....

+2  A: 

Why not just put named anchor tags between the chapters and link to those?

<a name='chapter_3'>&nbsp;</a>

Then your link can look like:

  <li>
    <a href='#chapter_3'>Wherein Mr. Toad Gains A Fresh Perspective</a>
  </li>
Pointy
Or `<h2 id="chapter_3">Wherein Mr. Toad Gains A Fresh Perspective</h2>` (which makes more sense than linking to a … space).
David Dorward
yes well whatever makes sense for the table of contents. Also I assumed that there'd already be markup and content in the sections themselves to represent section/chapter titles, etc. If all he's doing is gluing the sections together, it's easier to insert a blank anchor than to try and wrap an anchor around something at the front of each section.
Pointy
@Pointy: you can link to anything with an ID attribute in a modern browser. No more need for `<a name=...>`.
Mr. Shiny and New
Well, i cannot do so, because my table of content is not included on the same document window,but it is in different window say leftside of the document window( like any pdf reader,or epub reader, adobe digital edition etc).
ganapati
+1  A: 

You can use Javascript to get the height of a div. So, wrap each chatper in a div, give it a name or class name, then use javascript to find the height of the div.

TheGeekYouNeed