I am trying to open a HTML page using python script. With the following script the file opens in a new browser tab. How should I make it open in the same tab?
import webbrowser
import os
import urllib
chrome_path="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
webbrowser.register('chrome', None,webbrowser.BackgroundBrowser(chrome_path))
webbrowser.get('chrome').open(os.path.realpath('image.html'))
EDIT 1:
I tried adding
webbrowser.get('chrome').open(os.path.realpath('image.html'), new=1, autoraise=True)
it opens in the same browser but not in the same tab.
解决方案
I am afraid you need to do it through Javascript:
RefreshTab = ''
print RefreshTab % 'yourscript.py'