1

I have a web page that I would like to display in a Web View in my app. But the page has links. Is there any way I can suppress all links on a page when it is being displayed in a WebView.

Edit - 9/25

What I really mean by suppressing is that I dont want any of the links to display. So in my responsive application, all my links show up as a hamburger menu when I view it in a mobile. I dont want that to even display. Is that possible.

avsln
  • 653
  • 3
  • 8
  • 18

1 Answers1

0

Subscribe to webview's Navigating event and set e.Cancel = true.

There is a very good code sample in this answer on how to implement this with MVVM support. You can also refer this link for a more simple example.

EDIT 1 - as per updated question

You can do the same by using javascript injection to show or hide elements from DOM in WebView. Here is an answer that does something similar to intercept clicks on all elements.

Sharada Gururaj
  • 13,471
  • 1
  • 22
  • 50
  • Thank you Sharada. I will modify my question a little. Basically I dont want the links to be displayed in my Android or iOS app. – avsln Sep 25 '17 at 13:54
  • You can use javascript injection to remove the elements from DOM - you can refer this answer - https://stackoverflow.com/a/45644422/7292772 – Sharada Gururaj Sep 25 '17 at 14:14