| title | Documentation Overview |
|---|---|
| parent | WebView2 Package |
| nav_order | 2 |
twinBASIC WebView2 package provides complete Microsoft Edge WebView2 control integration, enabling you to embed modern web content in twinBASIC applications and achieve bidirectional interaction.
| Document | Description |
|---|---|
| Getting Started Guide | Quick start with WebView2 control |
| Index | Documentation index and functionality overview |
| Document | Description |
|---|---|
| WebView2 Control | Main control class, complete reference of all properties, methods, and events |
| Environment Options | WebView2 environment configuration options |
| Document | Description |
|---|---|
| HTTP Request | Web resource request object |
| HTTP Response | Web resource response object |
| Request Headers | HTTP request header management |
| Response Headers | HTTP response header management |
| Header Collection | HTTP header collection enumeration |
| Header Info | Single HTTP header information |
| Document | Description |
|---|---|
| Enumeration Types | All enumeration type definitions and descriptions |
| Deferred Callback | Deferred event and callback mechanism (re-entrancy issues) |
WebView21.Navigate "https://www.example.com"→ Refer to WebView2 Control - Navigation Methods
Dim result As Variant
result = WebView21.JsRun("document.title")→ Refer to WebView2 Control - JavaScript Interaction
' Twinbasic sends to JavaScript
WebView21.PostWebMessage "Hello!"
' JavaScript sends to Twinbasic
window.chrome.webview.postMessage("Hello from JS");→ Refer to WebView2 Control - Message Passing
WebView21.AddWebResourceRequestedFilter "*://*/*.png", wv2Image
Private Sub WebView21_WebResourceRequested(ByVal Request As WebView2Request, _
ByVal Response As WebView2Response)
' Handle request
End Sub→ Refer to WebView2 Control - Web Resource Interception
Private Sub WebView21_UserContextMenu(X As Single, Y As Single)
PopupMenu mnuCustomContext, vbPopupMenuRightButton, X, Y
End Sub→ Refer to WebView2 Control - Events
WebView21.PrintToPdf "C:\output.pdf"→ Refer to WebView2 Control - Advanced Features
WebView21.EnvironmentOptions.UserDataFolder = "C:\MyApp\Data"
WebView21.EnvironmentOptions.Language = "en-US"→ Refer to Environment Options
WebView2 (Main Control)
├── WebView2EnvironmentOptions (Environment Configuration)
├── WebView2Request (HTTP Request)
│ └── WebView2RequestHeaders (Request Headers)
│ └── WebView2HeadersCollection (Header Collection)
│ └── WebView2Header (Single Header)
└── WebView2Response (HTTP Response)
└── WebView2ResponseHeaders (Response Headers)
└── WebView2HeadersCollection (Header Collection)
└── WebView2Header (Single Header)
- ✅ Load URL web pages
- ✅ Load custom HTML strings
- ✅ Virtual host mapping
- ✅ PDF export
- ✅ Forward/backward navigation
- ✅ Page refresh
- ✅ Custom HTTP requests (POST, Headers)
- ✅ Execute JavaScript code
- ✅ Synchronously call JS functions
- ✅ Asynchronously call JS functions
- ✅ Bidirectional message passing
- ✅ Expose COM objects to JavaScript
- ✅ Deferred invocation mode (avoid re-entrancy)
- ✅ Navigation events
- ✅ Permission request events
- ✅ Script dialog events
- ✅ Download events
- ✅ Web resource interception
- ✅ Developer tools
- ✅ DevTools protocol
- ✅ Download manager
- ✅ Task manager
- ✅ Audio control
- ✅ Suspend/resume
- Install WebView2 Runtime
- Reference WebView2 package
- Add WebView2 control to form
→ Refer to Getting Started
Private Sub Form_Load()
' Note: All WebView21 member operations must be done after WebView21_Ready()
End Sub
Private Sub WebView21_Ready()
WebView21.DocumentURL = "https://www.example.com"
End Sub
Private Sub WebView21_NavigationComplete(ByVal IsSuccess As Boolean, _
ByVal WebErrorStatus As Long)
' Page loading complete
End Sub' Execute JS
WebView21.ExecuteScript "document.body.style.background = 'red'"
' Get JS return value
Dim title As Variant
title = WebView21.JsProp("document.title")' Twinbasic sends to JavaScript
WebView21.PostWebMessage "Hello"
Private Sub WebView21_JsMessage(ByVal Message As Variant)
' Receive JavaScript message
End Sub- Intercept HTTP requests
- Customize right-click menu
- Print PDF
- Virtual host mapping
Make sure to set Visible = True and properly set position and size.
Check if WebView2 Runtime is installed and review the Error event.
Set JsCallTimeOutSeconds property to increase timeout.
Use UseDeferredEvents = True and use UseDeferredInvoke = True in AddObject.
Handle permission requests in the PermissionRequested event.
- Windows 7 SP1 or higher
- WebView2 Runtime (Evergreen) 86.0.616.0 or higher
The WebView2 package follows its own license terms, see the LICENCE.md file in the package for details.
For questions or suggestions, please provide feedback through:
- Submit an Issue
- Visit twinBASIC community
Last updated: February 15, 2026