Nativescript: Send links outside of the app in WebView

Created on 13 Aug 2016  路  13Comments  路  Source: NativeScript/NativeScript

Hi,

We are trying to add blog like page in our app to make our clients to share with each other.we are using html tags for our shares because we need to add emicons or links to our shares and this blog page can also be access trough our web site.Right now we are using htmlview to show the shares.in html view links send user to outside our app to open their browsers but we cant show img tags in htmlview.But when we use webview we have 2 problems.First the links dont send user to outside of our app instead open that link inside the webview. Second when user clik the webview or image inside the webview zoom buttons appear and it allow user to zoom in inside the webview. we want to prevent this two behaviors.
is there anyway to achieve this.
Thanks

question

Most helpful comment

I don't understand why this has been closed. It's still an issue and should be solved in the core shouldn't it?

All 13 comments

Hello @tomylee001001

About question 1:
Perhaps, you can use the plugin for Web-view bi-directional communication
https://www.npmjs.com/package/nativescript-webview-interface

About question 2:
You can set isUserInteractionEnabled for you web-view and the user won't be able to interact with it.

Hi,
I look at the plugin you mentioned although i am not 100% sure but i dont think that plugin solve my problem.What i want to achieve is i want links in the webview act like links in the htmlview. for example if you tap the links in htmlview you automatically send to browser select for opening the link. htmlview works perfectly for this aspect for me but beause i also need to show user emoticons or smiley icons htmlview cant show images and need to switch to webview or if there is any alternative i need to use that.
Thanks

@tomylee001001 I'm not overly familiar with the webview or the htmlview, but couldn't you make your "links" look like links, but wire them up to a Javascript Click Event that would then allow you to open them in the device's browser? I'm not sure of the exact code you'd need to accomplish this but its probably where I'd start.

Hi @tomylee001001,
I am not sure that I understand your question in the right way, however my suggestion is to use openUrl method of the utils modules. This method would allow you to redirect to the browser. You could review my sample project here.

I hope this is applicable for you.

@tsonevn i am trying to make blog app like slack or whatsapp. My problem lies in the view item for showing the message. i need to both show links inside and/or smiley faces in the message text. therefor i am using html tags to format the message and using htmlview for showing them but as you know htmlview cant render img tags. so i am trying to use webview instead .

Hi @tomylee001001.
I have made some changes in my sample project, that might help you to resolve your issue. In my project I used WebView to display HTML content and on WebView tap event I redirect to the browser with openURL method. Could you review the sample project here.

@tsonevn thanks for the help but that didnt solve my problem either.in the end i decided to modify the source code of the webview for android and ios. i manage to modify the android code to my needs and now trying to do the same for ios.

I don't understand why this has been closed. It's still an issue and should be solved in the core shouldn't it?

Any news about this ?

hii @tomylee001001 ,
can you please share you code for solving the issue.

hii @tsonevn ,
question @TomaNikolov had is that when using WebView if src contains html hyperlinks, then if someone clicks it. it opens link in that WebView but insted of that. we want to open that link default android browser or open using openurl.

Hi @bhavincb,
you can review this thread in NativeScript forum, where it is demonstrated, how you can achieve this in NativeScript while building for Android.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vtisnado picture vtisnado  路  3Comments

Pourya8366 picture Pourya8366  路  3Comments

dhanalakshmitawwa picture dhanalakshmitawwa  路  3Comments

Leo-lay picture Leo-lay  路  3Comments

kn9ts picture kn9ts  路  3Comments