While the web-developer plugin is a nice tool, it seems a rather round-about way to get the DOM structure into a a file or script. Why would someone want to do it that way instead of just using existing tools in JavaScript or Perl to get the same information?
I took position (mistakenly) to mean X/Y which is available out of the broswer only and he wants to write it to a file in response to a mouse action. So I thought of chrome. Upon reflection though (thanks for calling me on it) there is obviously a Perl/JS solution. I'm playing around with one right now, Ajax. If I can finish something concise and correct I'll follow up with it.