Skip to content

Fix opening links with target=_blank#85

Merged
akissinger merged 1 commit intoakissinger:masterfrom
The-Compiler:target-blank-links
Nov 14, 2024
Merged

Fix opening links with target=_blank#85
akissinger merged 1 commit intoakissinger:masterfrom
The-Compiler:target-blank-links

Conversation

@The-Compiler
Copy link
Collaborator

A <a href="..." target="_blank"> element can be used by websites to request a link to be opened in a new tab. For some reason, some links in mails seem to have target="_blank" set too.

When such a link is clicked, QtWebEngine emits a newWindowRequested signal instead of opening the link directly:
https://doc.qt.io/qt-6/qwebenginepage.html#newWindowRequested

This commit extracts the link opening code from acceptNavigationRequest to a _handle_link helper method, and also calls that when said signal is emitted.

A <a href="..." target="_blank"> element can be used by websites to request a
link to be opened in a new tab. For some reason, some links in mails seem to
have target="_blank" set too.

When such a link is clicked, QtWebEngine emits a newWindowRequested signal
instead of opening the link directly:
https://doc.qt.io/qt-6/qwebenginepage.html#newWindowRequested

This commit extracts the link opening code from acceptNavigationRequest
to a _handle_link helper method, and also calls that when said signal is
emitted.
@The-Compiler The-Compiler mentioned this pull request Oct 7, 2024
19 tasks
@akissinger akissinger merged commit f8cf8d1 into akissinger:master Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants