Home > Software design >  How to open page in browser from html file on disk with user default webrowser? (not IE)
How to open page in browser from html file on disk with user default webrowser? (not IE)

Time:01-07

I used

webbrowser.open('file://page/index.html')

and page was opened with IE. How can i change this to user webbrowser, e.g. chrome, opera and each other?

CodePudding user response:

webbrowser.open() should call the default webbrowser, whatever it may be.

If you want a specific other browser, you can use register() to register it, and then call open() in combination with get(), e.g.

webbrowser.register('chrome',
    None,
    webbrowser.BackgroundBrowser("C://Program Files (x86)//Google//Chrome//Application//chrome.exe"))

webbrowser.get('chrome').open('file://page/index.html')
  •  Tags:  
  • Related