Opening a URL with Default Browser

suggest change

To simply open a URL, use the webbrowser.open() method:

import webbrowser
webbrowser.open("http://stackoverflow.com")

With the default new=0, the method tries to open the URL in the same browser window. If no window is open, it opens the operating system's default browser. The open method supports the following parameters:

Note, the new and autoraise arguments rarely work as the majority of modern browsers refuse these commands.

Webbrowser can also try to open URLs in new windows with the open_new method:

import webbrowser
webbrowser.open_new("http://stackoverflow.com")

This method is commonly ignored by modern browsers and the URL is usually opened in a new tab. Opening a new tab can be tried by the module using the open_new_tab method:

import webbrowser
webbrowser.open_new_tab("http://stackoverflow.com")

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents