webbrowser.open_new alternatives for Windows

Pierre Rouleau prouleau at impathnetworks.com
Tue Mar 23 05:36:21 CET 2004

Robert wrote:

> how can i open a _NEW_ browser window on Windows ?
> (It should be browser independent. at least for IE, Mozilla &
> Netscape)
> i found a snippet/suggestion for "IE only" in this group but it
> doesn't work, open also in old window:
> from win32com.client import Dispatch
> def start(url):
>     w=Dispatch("InternetExplorer.Application")
>     w.Navigate2(url)
>     w.visible=1
> start("http://www.python.org")
> start("http://www.zope.com")
> Robert

Under Windows, you can use os.startfile() to start the application 
associated with the file extension:

 >>> fname = 'c:/dev/python/_doc/python.html'
 >>> import os
 >>> os.startfile(fname)

You will launch a new browser instance for each os.startfile() and it 
will launch the default browser, whatever it is.


More information about the Python-list mailing list