Reputation: 1
I'm a python beginner and I want my code to open a local HTML page with parameters (e.g. /help/index.html#1)
. Right now I have the below code:
def openHelp(self, helpid):
import subprocess
import webbrowser
import sys, os
directory = os.getcwd()
if sys.platform == 'darwin': # For macOS
url = 'file://' + directory + '/help/index.html' + '#{}'.format(str(helpid))
webbrowser.get().open(url)
else:
url = 'help/index.html' + '#{}'.format(str(helpid))
webbrowser.open(url)
The code opens the webpage, however without the parameters (#helpid)
. Where did I make a mistake? Thanks in advance!
Upvotes: 0
Views: 637
Reputation: 2640
Your code looked fine to me. I tried it and it worked. You have to call it with openHelp("",1). The #helpid parameter was added correctly. Make sure it is a number.
Upvotes: 1