I have an WebHTMLViewer set inside a Rectangle, and it seems like the WebHTMLViewer inherits the background color of the Rectangle it’s inside of, in lieu of the background color of the HTML it’s loading. Also, the WebHTMLViewer appears to ignore Styling (setting Me.Style.BackgroundColor
for instance).
That doesn’t surprise me.
FWIW, the WebHTMLViewer acts differently depending on how the content is loaded. If you use LoadHTML it simply adds the content to the containing div. If you use LoadURL, the div is changed to an iframe and the page is loaded like it’s a mini browser.
It would help to know which you are doing.
Hi Greg, I am in fact using the LoadHTML (grabbed from the database in realtime). As a work-around I’ve placed another Rectangle behind the WebHTMLViewer, set it to the color I wanted, and it works for this particular situation. Overall the WebHTMLViewer is a great way to present externally authored content, so again I have no complaints - it’s doing the job I need it for.
Aestetically speaking however… that control could use some attention
If you’re using LoadHTML then you shouldn’t have HTML
, HEAD
, or BODY
tags. That method just inserts the HTML passed in to the document at the position of the WebHTMLViewer. So valid content when using LoadHTML would be just those elements you want to display, something like:
<p>SomeContent</p>
You can use inline styles, IDs or classnames to apply styling to those elements, but be aware that they may also be applied elsewhere that you don’t intend them to be if you choose classnames:
<div style="background: #f0f;">SomeContent</div>
Great info - and all proceed with caution. Thanks Anthony!