Skip to Content

I’ve been thinking about making a Mozilla/Firefox extension for a long while now. The project that I have in mind is a solution for the problem that I have when printing an SDN forum thread in Firefox.  Printed threads aren’t WYSIWYG at all. Everything is cluttered and things aren’t shown as they should be, or are incomplete.

Unlike Internet Explorer, Firefox doesn’t have any context print functionality. The possibility does exist though. You only need to install the Print extension from e.g. and you get a print functionality when you click the right mouse button. So what’s the problem? Without under appreciating this extension, it does the same as File/Print a.k.a. Ctrl+P, so we still have the same problem here since it (tries to) print(s) the whole page. I’m only interested in the forum thread itself as such. The menus are rather useless on paper anyway. I saw the other day in a forum post that I wasn’t the only one having problems with printing forum threads. So it was time to find a solution to the problem.

The solution is rather simple. Since the content of a forum thread is shown in an iframe, one only has to print that one. So I decided to have a go and create a Mozilla/Extension. There is a good guide available at As you can see, this isn’t something that you can create in a few moments – or as we say in Flemish: between the soup and the potatoes. It isn’t that it is difficult as such, but there’s a whole procedure to follow. It is positively overkill for what I wanted to achieve. You’ll see why in a moment.

For some reason bookmarklets are out of fashion. Until a couple of years ago they were as popular as Java applets, but both have since vanished. The only bookmarklet that is still widely used is the open web directory crawler that shows all photos in one page. “What is he talking about?” I hear (some of) you say. Well, bookmarklets are just JavaScript code that fits or is squeezed – the code can be rather lengthy – into one line and bookmarked. The only thing you need to do is retrieve the web page you need and open this bookmarklet. The JavaScript will be executed on the page you’ve retrieved. And that’s exactly what we need: a JavaScript that prints only the frame containing the SDN forum thread.

So we’ve now reached the point where some work needs to be done. Start Firefox – you probably did that already to read this Web log – and start the Bookmark Manager (second item under the Bookmark menu). Create a new bookmark (first icon on the toolbar) and you’ll see this popup.


Fill in an appropriate name and put the following code in the Location:

class="style1"> javascript:document.getElementById(%22iframecontent%22).contentWindow.print()   

getElementById was introduced in DOM (Document Object Model, see also Level 2 and returns the element whose ID is specified. The ID we specify (iframecontent) is the iframe containing the forum thread. The contentWindow property returns the window object for the frame

Click on OK to save. Congratulations, you’ve made a bookmarklet. It couldn’t be simpler, could it? My dream of making a Mozilla/Firefox is put on ice until I find a more complicated problem to solve.


Update: Check the Super (re)size it. web log if you want to print web logs.

To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Former Member
    It is always these solutions that use elegance instead of brute force, which are the best! I see that you master the technique of one-line solutions. Tested perfectly also in IE!
    Bye, brian
    1. Former Member

      Only problems is that suddenly SDN changes the name of the iframe from iframecontent to something else.
      Therefore, I would like very much that SDN implements this functionality in the forums (it really isn’t very complex todo). But it is still a great workaround which has helped me alot.

  2. Former Member

    I always wondered if it was possible to do something like that.  I always hate showing someone soemthing great that is on a page but the print version is terrible.  This is very good.


Leave a Reply