01-30-2013 08:04 PM
Container{
id: advertContainer
background: Color.create("#2b2b2b")
preferredHeight: 100.0
//touchPropagationMode: TouchPropagationMode.PassThrough
//touchPropagationMode: TouchPropagationMode.None
//touchPropagationMode: TouchPropagationMode.Full
horizontalAlignment: HorizontalAlignment.Fill
WebView{
id: adView
touchPropagationMode: TouchPropagationMode.PassThrough
onNavigationRequested: {
console.log("NavigationRequested: " + request.url + " navigationType=" + request.navigationType)
if (!shouldAcceptNavigationToUrl(request.url)) {
request.action = WebNavigationRequestAction.Ignore
invokeBrowser.trigger("bb.action.OPEN")
invokeQuery.uri = request.url
}
}
url: "local:///assets/advert.html"
horizontalAlignment: HorizontalAlignment.Center
}
} // end of advertContainer
attachedObjects: [
Invocation {
id: invokeBrowser
query: InvokeQuery {
id: invokeQuery
invokeTargetId: "sys.browser"
}
}
]Hi,
I'm trying to launch the browser from webview when a link in the webview is clicked.
I dont want the webview to change at all when the link is clicked, only for the external browser to be launched and open the link clicked in Webview.
The above code is where I am at the moment.
I would be greatfull for any advice on how to proceed.
Regards
Dan
02-01-2013 11:36 AM
Hi,
Did you change the action property of the WebNavigationRequest or call WebNavigationRequest::ignore() ?
More details in the docs for
Shadid
02-02-2013 10:47 AM
I got it working as follows:
Container {
id: advertContainer
background: Color.create("#2b2b2b")
preferredHeight: 100.0
horizontalAlignment: HorizontalAlignment.Fill
WebView {
id: adView
url: "local:///assets/advert.html"
horizontalAlignment: HorizontalAlignment.Center
onNavigationRequested: {
if (request.url == "local:///assets/advert.html") {
request.action = WebNavigationRequestAction.Accept
} else {
request.action = WebNavigationRequestAction.Ignore
invokeQuery.uri = request.url
invokeBrowser.trigger("bb.action.OPEN")
}
}
}
attachedObjects: [
Invocation {
id: invokeBrowser
query: InvokeQuery {
id: invokeQuery
invokeTargetId: "sys.browser"
onQueryChanged: invokeQuery.updateQuery();
}
}
]
} // end of advertContainer
This part isnt in the docs:
invokeTargetId: "sys.browser"
onQueryChanged: invokeQuery.updateQuery();
Just to recap, this allows the opening of a link in webview to be launched in the broswer instead of the webview, leaving the webview unchanged.