Firefox and the Python webbrowser module

I’d like to be able to open a window without browser chrome from the Python webbrowser module. After a bit of poking around, it seems to be possible. This will only work with Mozilla, and it might only work on Linux (although it should be OK on Windows). The complexity in doing it is that you can’t specify a window size or configuration when calling However, JavaScript can: the function can specify no-chrome, window sizes, the lot. But you can’t just call'"...")'), because then you’ll have two windows; the one that ran the JS and the one the JS opened. JS can’t close the one that ran the JS, because it wasn’t opened by JS. The solution? Chrome windows:

import webbrowser
moz = webbrowser.get('mozilla')'javascript:void("","winname","chrome"))')

It should be possible to make this work for IE as well, because IE allows a child window to close its parent, even if the parent wasn’t opened by JS. However, I don’t need that at the moment; if I ever release this app that I’m using this for (it’s an example of Browser as Desktop UI) then I’ll make it cross-browser.

I'm currently available for hire, to help you plan, architect, and build new systems, and for technical writing and articles. You can take a look at some projects I've worked on and some of my writing. If you'd like to talk about your upcoming project, do get in touch.

More in the discussion (powered by webmentions)

  • (no mentions, yet.)