-2

When trying to to use '#' to specify anchor point in a webpage using the webbrowser lib, it seem to only work on websites, and not on local html files webbrowser.open(https://docs.python.org/library/webbrowser.html#webbrowser.open) works, but webbrowser.open(file://C:\path\to\webbrowser.html#webbrowser.open) does not.

Is there something I am missing to be able to do it, or is it simply not supported? If so, are there any alternatives?

I need the html page to be available offline

Tomas Berger
  • 173
  • 1
  • 3
  • 15
  • That's not the same thing. – Peter Wood Jul 19 '21 at 12:06
  • @PeterWood Not certain what you mean? If I open the file `file://C:\path\to\webbrowser.html#webbrowser.open` in my browser it jump correctly to the headline. However, doing so using the webbrowser lib it does not – Tomas Berger Jul 20 '21 at 09:33

1 Answers1

-1

Just do this -

webbrowser.open_new(C:/path/to/webbrowser.html)

This will open html file offline

PCM
  • 2,881
  • 2
  • 8
  • 30
  • 1
    This does not quite anwser my question. I am able to open the file, but not at the correct anchor point `#webbrowser.open` – Tomas Berger Jul 20 '21 at 09:34