File tree 3 files changed +16
-0
lines changed
3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,10 @@ type WebView interface {
58
58
// properly, webview will re-encode it for you.
59
59
Navigate (url string )
60
60
61
+ // SetHtml sets the webview HTML directly.
62
+ // The origin of the page is `about:blank`.
63
+ SetHtml (html string )
64
+
61
65
// Init injects JavaScript code at the initialization of the new page. Every
62
66
// time the webview will open a the new page - this initialization code will
63
67
// be executed. It is guaranteed that code is executed before window.onload.
Original file line number Diff line number Diff line change @@ -120,6 +120,13 @@ func (e *Chromium) Navigate(url string) {
120
120
)
121
121
}
122
122
123
+ func (e * Chromium ) NavigateToString (htmlContent string ) {
124
+ _ , _ , _ = e .webview .vtbl .NavigateToString .Call (
125
+ uintptr (unsafe .Pointer (e .webview )),
126
+ uintptr (unsafe .Pointer (windows .StringToUTF16Ptr (htmlContent ))),
127
+ )
128
+ }
129
+
123
130
func (e * Chromium ) Init (script string ) {
124
131
_ , _ , _ = e .webview .vtbl .AddScriptToExecuteOnDocumentCreated .Call (
125
132
uintptr (unsafe .Pointer (e .webview )),
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ type browser interface {
39
39
Embed (hwnd uintptr ) bool
40
40
Resize ()
41
41
Navigate (url string )
42
+ NavigateToString (htmlContent string )
42
43
Init (script string )
43
44
Eval (script string )
44
45
NotifyParentWindowPositionChanged () error
@@ -389,6 +390,10 @@ func (w *webview) Navigate(url string) {
389
390
w .browser .Navigate (url )
390
391
}
391
392
393
+ func (w * webview ) SetHtml (html string ) {
394
+ w .browser .NavigateToString (html )
395
+ }
396
+
392
397
func (w * webview ) SetTitle (title string ) {
393
398
_title , err := windows .UTF16FromString (title )
394
399
if err != nil {
You can’t perform that action at this time.
0 commit comments