How do I make a Javascript "Mini-browser"?

I want to make a web application that can do sentence diagramming (like we did in grade school), on a website that a user is viewing.

My server has a “dictionary” database that basically maps common words in English to their part of speech (noun, verb, adjective, etc). I’d like for a user of my site to be able to go to any site with text content, say a news blog, highlight a sentence on the page, and then right click or something to activate a javascript program, which will communicate with my site via HTTP POST (or better yet, AJAX), and send back a diagrammed sentence of the selection (or, a minimum equivalent, just a list identifying the part of speech of each word).

As far as I can tell, the big hurdle is: I need to run my javascript programs on other websites. Which is not possible of course. I thought about using iframes to do this, but if the src is from a different domain, you can’t access or manipulate the child window’s innerHTML, so that approach won’t work.

I was thinking I may be able to build a “browser within a browser” using Javascript. When a user comes to my site, clicks on “mini-browser”, it will download javascript to the client which will basically act as a proxy browser. The user would be able to type in a URL or follow a link just as they would on Firefox or Explorer, except within this browser, my own Javascript/AJAX functions will be available that will let me add tags to the content of the web page being viewed, and POST to my server the information necessary to do the sentence diagramming.

Is this a feasible approach? I have not been able to find anything like it, but I’m not really sure what it would be called so maybe I’m not doing the right searches. Anyways, I’m just curious how difficult this would be to implement, and what potential security or legal issues there could be.

I tried to keep this brief, but if something isn’t clear I can add more detail.



What about making a browser plugin/extension to actually add this as an option in the right click menu?

That thought did cross my mind, but I’m not familiar at all with browser plug-ins or extension technology. I think they are Javascript-based right? It should work as far as the right -click goes, but will it let me access the Document’s innerHTML (of the page being viewed) and tag individual words with <id>s, and do all the Javascript list-building and posting to my server?

If so, then that would be a great solution (and I’ll have to start learning about plugins!)


You could also make a bookmarklet. Biggest restriction is the user will need to manually run the bookmarklet on each page load. But, once run, it will have power to do all of that. You can put all the code in the bookmarklet itself, or, have the bookmarket just add the remote script(hosted on your domain) to the dom. Once that’s done, you have pretty much full access.

making an entry in the browsers native context menu upon right click is still out of the question, but you could easily display your own menu.