Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open link from webview #35

Open
peppeg85 opened this issue Jul 5, 2018 · 2 comments
Open

open link from webview #35

peppeg85 opened this issue Jul 5, 2018 · 2 comments

Comments

@peppeg85
Copy link

peppeg85 commented Jul 5, 2018

hi, i feed the webview from an html source, how can i capture the tap on a link event to open the link with an external browser?
i've seen the various functions like

function handleEventFromWebView(){
oWebViewInterface.on('anyEvent', function(eventData){
// perform action on event
});
}

function emitEventToWebView(){
oWebViewInterface.emit('anyEvent', eventData);
}

function callJSFunction(){
oWebViewInterface.callJSFunction('functionName', args, function(result){

});

}

i think i could use one of them, but how capture the 'tap on link' event (ios and android)? thank you

@mtenus
Copy link

mtenus commented Oct 14, 2019

Hi

@peppeg85 You could use an event 'loadStarted', then handle link and use "openUrl" method from utils library

  webView.on('loadStarted', (args: LoadEventData) => {
    if(args.url.indexOf('some_string')==-1) {
            utils.openUrl(args.url);
        }
      });

@peppeg85
Copy link
Author

hello, thank you, but I solved with the https://github.com/Notalib/nativescript-webview-ext plugin, thank you again,

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

No branches or pull requests

2 participants