[SailfishDevel] Webview and clicking on external link

Raine Mäkeläinen raine.makelainen at jolla.com
Mon Feb 1 07:59:57 UTC 2016


Hi Zoltan,

Your example snippet looks valid. There's no need for goExternal kind of functions. Only thing that I can image is that you're not actually clicking a link rather something that resembles link clicking from user point of view such as JavaScript/CSS highlighting + DOM manipulation without anchors element. Try your example with e.g. https://en.m.wikipedia.org url.

You might see linkHovered(string hoveredUrl, string hoveredTitle) signal being emitted. Maybe this could help you. You still need to have proper navigation ignoring code on navigationRequested signal handler.

HTH,
Raine


________________________________
Lähettäjä: devel-bounces at lists.sailfishos.org [devel-bounces at lists.sailfishos.org] käyttäjän Zoltán Lutor [zoltan.lutor at gmail.com] puolesta
Lähetetty: 28. tammikuuta 2016 22:55
Vastaanottaja: Sailfish OS Developers
Aihe: [SailfishDevel] Webview and clicking on external link

Hi,

Any idea how to open link clicked in webview in browser application?
Code below does not do the trick - rather opens link inside the webview itself...

http://doc.qt.io/qt-5/qml-qtwebkit-webview.html#onNavigationRequested-signal

WebView {

        id: webViewer

        anchors.fill: parent

        onNavigationRequested : {

            console.debug("request.url: ", request.url)

            if (request.navigationType === WebView.LinkClickedNavigation) {

                request.action = WebView.IgnoreRequest

                Qt.openUrlExternally(request.url)

            }

        }

    }


Thx,


Zoltan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20160201/6c8691f0/attachment.html>


More information about the Devel mailing list