views:

15

answers:

2

I am trying to write a firefox plugin which could allow people to annotate their bookmarked web pages and store the annotations locally.

I am doing this by inserting appropriate div elements inside the body of the page and attaching appropriate handlers for allowing drag/drop kind of interactions on these elements.

While I can easily add the elements on a html page, I am not able to do so in those pages that are non-html but supported by the browser - example an image, or a plain txt file.

I guess the basic problem is that for these documents there is no body element in the dom and hence I cannot append my divs correctly.

Is there anything I can do to add the divs correctly to these non html docs on the browsers so that it renders correctly?

Thanks. Kapil

A: 

Your plugin would probably have to create a HTML pages for non-HTML content. For example, if the user is viewing an image, the browser could create a local HTML page containing the image. If the user wants to annotate a text document, the local HTML page could contain the text document within pre tags to preserve its formatting.

Evan Kroske
A: 

I suggest that your Firefox add-on wrap the non-HTML page with a HTML wrapper. E.g.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;

<html>
  <head>
  </head>
  <body>
    *** NON-HTML CONTENT IN HERE ***
  </body>
</html>

That way you get the platform you need for putting in the annotations.

Gert G