Page 1 of 1

html code on the selected url

Posted: Thu Apr 14, 2022 8:02 am
by pushca
hi! can I upload my html code to the specified url? In the temple, I achieved this in this way:
Form1.Chromium1.Browser.MainFrame.LoadString('<HTML>', 'https://musite.com');

I tried to do WVBrowser1.NavigateToString(str); but it loads the page on about:blank

Re: html code on the selected url

Posted: Sat Apr 16, 2022 12:53 pm
by salvadordf
The WebView2 API only allows you to call TWVBrowserBase.NavigateToString with one parameter for the HTML contents.

https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.1185.39#navigatetostring
Initiates a navigation to htmlContent as source HTML of a new document.

public HRESULT NavigateToString(LPCWSTR htmlContent)

The htmlContent parameter may not be larger than 2 MB (2 * 1024 * 1024 bytes) in total size. The origin of the new page is about:blank.
WebView2 doesn't allow you to specify the origin URL in this case.