Prevent HtmlViewer from loading remote content

I want to mimic the “Load Remote Content” feature from Mail in my app.

For the images there is

me.WKWebViewMBS.Preferences.loadsImagesAutomatically = False

But how do I prevent the HtmlViewer from - for instance - contacting the Google fonts in the example below?

<link href=


rel="stylesheet" type="text/css" />

<style type="text/css">


@import url(,400,500,700);


As always plugin solutions are welcome.

I scan through the html about to be loaded into the HTMLViewer, and replace all URL targets with my repstr1, as follows:

repstr1 = "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="       // Transparent gif, 1px x 1px

That was my first thought, too. I just hoped that there would be a more elegant solution.

Actually, it’s not that easy.

The images are fished out by WKWebViewMBS.Preferences. Then I have normal href links. The only links I need to remove are the other links like the one above.

It seems like RegEx can be used to scan and replace those links if you fetch the HTML first, do the scan & replace, then load that result to the HTMLViewer. I think that is what @TimStreater meant he was doing?

Yes, that’s what he meant. However, I can easily block the images with the MBS plugin. Now I need to find a regex to differentiate the above shown links with normal href ones.


There’s nothing elegant about working with the HTMLViewer.

1 Like

This true. The feature has some interesting challenges.

I’ll add a few new properties for our plugin classes for WebKit.

and it looks like the limitsNavigationsToAppBoundDomains flag may do it.
Since your app may not have an app bound domain, it simply doesn’t load anything.

browser.WKWebView.Configuration.limitsNavigationsToAppBoundDomains = true

Please try with next plugin version.

1 Like