Beispiel #1
0
 def acceptNavigationRequest(self, url, navType, isMainFrame):
     if not isMainFrame:
         return True
     from aqt import mw
     # ignore href=#
     if url.toString().startswith(mw.serverURL()):
         return False
     # load all other links in browser
     openLink(url)
     return False
Beispiel #2
0
 def acceptNavigationRequest(self, url, navType, isMainFrame):
     if not isMainFrame:
         return True
     from aqt import mw
     # ignore href=#
     if url.toString().startswith(mw.serverURL()):
         return False
     # load all other links in browser
     openLink(url)
     return False
Beispiel #3
0
 def acceptNavigationRequest(self, url, navType, isMainFrame):
     if not isMainFrame:
         return True
     # data: links generated by setHtml()
     if url.scheme() == "data":
         return True
     # catch buggy <a href='#' onclick='func()'> links
     from aqt import mw
     if url.matches(QUrl(mw.serverURL()), QUrl.RemoveFragment):
         print("onclick handler needs to return false")
         return False
     # load all other links in browser
     openLink(url)
     return False
Beispiel #4
0
 def acceptNavigationRequest(self, url, navType, isMainFrame):
     if not isMainFrame:
         return True
     # data: links generated by setHtml()
     if url.scheme() == "data":
         return True
     # catch buggy <a href='#' onclick='func()'> links
     from aqt import mw
     if url.matches(QUrl(mw.serverURL()), QUrl.RemoveFragment):
         print("onclick handler needs to return false")
         return False
     # load all other links in browser
     openLink(url)
     return False
Beispiel #5
0
    def acceptNavigationRequest(self, url: QUrl, navType: Any,
                                isMainFrame: bool) -> bool:
        if not self.open_links_externally or "_anki/pages" in url.path():
            return super().acceptNavigationRequest(url, navType, isMainFrame)

        if not isMainFrame:
            return True
        # data: links generated by setHtml()
        if url.scheme() == "data":
            return True
        # catch buggy <a href='#' onclick='func()'> links
        from aqt import mw

        if url.matches(QUrl(mw.serverURL()), cast(Any, QUrl.RemoveFragment)):
            print("onclick handler needs to return false")
            return False
        # load all other links in browser
        openLink(url)
        return False