Y
Y
yong2019-04-19 12:04:23
Python
yong, 2019-04-19 12:04:23

Opening a browser tab in the same window on a QWebEngineView. Why is referrer not being passed?

There is a code:

class WebEnginePage(QWebEnginePage):

    def createWindow(self, _type):
        page = WebEnginePage(self)
        page.urlChanged.connect(self.on_url_changed)
        return page

    @pyqtSlot(QUrl)
    def on_url_changed(self, url):
        page = self.sender()
        self.setUrl(url)
        page.deleteLater()

class MainWindow(QMainWindow):
    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)
        self.browser = QWebEngineView()
        page = WebEnginePage(self.browser)
        self.browser.setPage(page)
        self.browser.setUrl(QUrl("http://yandex.ru"))

When navigating through any site from Yandex search results, or simply when navigating a link with target="_blank" ... In the program, the page opens in the same window, but the counters see such a transition incorrectly without a referrer. Seems like a direct entry. Tested from my sites the same way .. If in a normal browser I go with target="_blank" then the referrer is visible to the transition and the site from which the transition was displayed is displayed. If I switch from the program with the code shown above, it goes as a direct entry. Help me to understand. Thank you!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question